Unable to access Synology NAS using sftp from inside a docker container

What is the problem you are having with rclone?

I'm trying to use rclone inside a docker container to access files in a Synology NAS using sftp and it is not connecting to the Synology nas from inside the container, but from outside it works well. I have no idea why and I'm hitting my head trying to figure out why. Using an alpine image for docker, thought it was that. Installed and alpine vm, tested and it works. So summary:

rclone sftp to Synology from Alpine vm = Works
rclone sftp to Synology from docker = Does not work
rclone smb to Synology from docker = Works
rclone sftp to ubuntu from docker = Works
rclone smb to ubuntu from docker = Works

I could use smb to connect, but I just want to know why sftp is giving me problems with Synology only from the container

Also tested an docker container with ubuntu instead of alpine, same problem.

Run the command 'rclone version' and share the full output of the command.

rclone v1.62.2

  • os/version: alpine 3.18.2 (64 bit)
  • os/kernel: 6.1.35-0-lts (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.20.2
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

SFTP to a Synology NAS

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Same command from docker and alpine vm

rclone config create DESTINATION sftp host=192.168.10.200 user=username pass=$(echo "password" | rclone obscure -) -vv
rclone ls DESTINATION:/directory -vv

The rclone config contents with secrets removed.

config is created on the fly, is shown in the logs

A log from the command with the -vv flag

Log from the Alpine VM:

rclone config create DESTINATION sftp host=192.168.10.200 user=username pass=$(echo "password" | rclone obscure -) -vv

2023/06/24 02:41:15 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "config" "create" "DESTINATION" "sftp" "host=192.168.10.200" "user=username" "pass=password" "-vv"]
2023/06/24 02:41:15 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/06/24 02:41:15 DEBUG : Saving config "pass" in section "DESTINATION" of the config file
2023/06/24 02:41:15 DEBUG : Saving config "host" in section "DESTINATION" of the config file
2023/06/24 02:41:15 DEBUG : Saving config "user" in section "DESTINATION" of the config file
2023/06/24 02:41:15 DEBUG : DESTINATION: config in: state="", result=""
2023/06/24 02:41:15 DEBUG : DESTINATION: config out: out=<nil>, err=<nil>
[DESTINATION]
type = sftp
pass = *** ENCRYPTED ***
host = 192.168.10.200
user = username
2023/06/24 02:41:15 DEBUG : rclone: Version "v1.62.2" finishing with parameters ["rclone" "config" "create" "DESTINATION" "sftp" "host=192.168.10.200" "user=username" "pass=password" "-vv"]
--
rclone ls DESTINATION:/directory -vv

2023/06/24 02:42:27 DEBUG : rclone: Version "v1.62.2" starting with parameters ["rclone" "ls" "DESTINATION:/directory" "-vv"]
2023/06/24 02:42:27 DEBUG : Creating backend with remote "DESTINATION:/directory"
2023/06/24 02:42:27 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: New connection 192.168.1.167:52008->192.168.10.200:22 to "SSH-2.0-OpenSSH_8.2"
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: Running shell type detection remote command: echo ${ShellId}%ComSpec%
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: Remote command result: %ComSpec%
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: Shell type "unix" detected (set option shell_type to override)
2023/06/24 02:42:28 DEBUG : Saving config "shell_type" in section "DESTINATION" of the config file
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: Using root directory "/directory"
      362 db.properties
     7877 http.properties
    13099 http.properties.rv
       67 loader.properties
      241 log4j.properties
      545 logging.properties
      323 login.conf
      134 system.properties
    23962 webdefault.xml
2023/06/24 02:42:28 DEBUG : 11 go routines active
2023/06/24 02:42:28 DEBUG : sftp://username@192.168.10.200:22//directory: Closing 1 unused connections

Log from the docker container

rclone config create DESTINATION sftp host=192.168.10.200 user=username pass=$(echo "password" | rclone obscure -) -vv

2023/06/24 14:43:35 DEBUG : rclone: Version "v1.62.2" starting with parameters ["/usr/bin/rclone" "config" "create" "DESTINATION" "sftp" "host=192.168.10.200" "user=username" "pass=zzY9rxmJDYsKv0zI2698lubGwh8cIQi7" "-vv"]
2023/06/24 14:43:35 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
2023/06/24 14:43:35 DEBUG : Saving config "host" in section "DESTINATION" of the config file
2023/06/24 14:43:35 DEBUG : Using default permissions for config file: -rw-------
2023/06/24 14:43:35 DEBUG : Saving config "user" in section "DESTINATION" of the config file
2023/06/24 14:43:35 DEBUG : Saving config "pass" in section "DESTINATION" of the config file
2023/06/24 14:43:36 DEBUG : DESTINATION: config in: state="", result=""
2023/06/24 14:43:36 DEBUG : DESTINATION: config out: out=<nil>, err=<nil>
[DESTINATION]
type = sftp
host = 192.168.10.200
user = username
pass = *** ENCRYPTED ***
2023/06/24 14:43:36 DEBUG : rclone: Version "v1.62.2" finishing with parameters ["/usr/bin/rclone" "config" "create" "DESTINATION" "sftp" "host=192.168.10.200" "user=username" "pass=zzY9rxmJDYsKv0zI2698lubGwh8cIQi7" "-vv"]

rclone ls DESTINATION:/directory -vv

2023/06/24 14:43:36 DEBUG : rclone: Version "v1.62.2" starting with parameters ["/usr/bin/rclone" "ls" "DESTINATION:/directory" "-vv"]
2023/06/24 14:43:36 DEBUG : Creating backend with remote "DESTINATION:/directory"
2023/06/24 14:43:36 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2023/06/24 14:43:36 DEBUG : pacer: low level retry 1/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:60108->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:36 DEBUG : pacer: Rate limited, increasing sleep to 200ms
2023/06/24 14:43:36 DEBUG : pacer: low level retry 2/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:60118->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:36 DEBUG : pacer: Rate limited, increasing sleep to 400ms
2023/06/24 14:43:36 DEBUG : pacer: low level retry 3/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:60126->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:36 DEBUG : pacer: Rate limited, increasing sleep to 800ms
2023/06/24 14:43:36 DEBUG : pacer: low level retry 4/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33206->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:36 DEBUG : pacer: Rate limited, increasing sleep to 1.6s
2023/06/24 14:43:37 DEBUG : pacer: low level retry 5/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33218->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:37 DEBUG : pacer: Rate limited, increasing sleep to 2s
2023/06/24 14:43:39 DEBUG : pacer: low level retry 6/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33224->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:41 DEBUG : pacer: low level retry 7/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33236->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:43 DEBUG : pacer: low level retry 8/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33246->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:45 DEBUG : pacer: low level retry 9/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:33248->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:47 DEBUG : pacer: low level retry 10/10 (error couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:41668->192.168.10.200:22: read: connection reset by peer)
2023/06/24 14:43:47 Failed to create file system for "DESTINATION:/directory": NewFs: couldn't connect SSH: ssh: handshake failed: read tcp 192.168.10.172:41668->192.168.10.200:22: read: connection reset by peer

My test Dockerfile

FROM alpine:latest

# enable community repository?

RUN sed -i '/community/s/^#//' /etc/apk/repositories

# install packages

RUN apk update
RUN apk upgrade
RUN apk add --no-cache bash
RUN apk add --no-cache zip
RUN apk add --no-cache curl
RUN apk add --no-cache gcompat
RUN update-ca-certificates
RUN rm -rf /var/cache/apk/*

# download rclone

RUN curl https://rclone.org/install.sh | bash

# copy startup script

COPY test.sh test.sh

ENTRYPOINT [ "./test.sh" ]

test.sh script

#!/bin/sh

rclone config create DESTINATION sftp host=192.168.10.200 user=user pass=$(echo "password" | rclone obscure -) -vv
rclone ls DESTINATION:/directory -vv

I do not think it has anything to do with rclone but rather your docker setup

ssh: handshake failed: read tcp 192.168.10.172:60108->192.168.10.200:22: read: connection reset by peer

error suggests some network problem.

I would try to run sftp -vv user@IP from inside docker to get more details.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.