Unable to connect to remote machine via SFTP

What is the problem you are having with rclone?

I am unable to SFTP into a remote machine and run rclone but I am able to SSH into the machine. When attempting to sftp, the connection closes. Not sure what's causing the connection to fail.

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

$ rclone version
rclone v1.68.2
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 5.15.0-79-generic (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.3
- go/linking: static
- go/tags: none

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

SFTP

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

ssh my_username@10.11.8.52 - able to connect

sftp -i ~/.ssh/id_ed25519 -P 22 my_username@10.11.8.52 - does not work

sudo rclone ls my-machine:/C:/my-data/ - does not work


Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

[my-machine]
type = sftp
shell_type = powershell
host = XXX
port = 22
user = XXX
pass = XXX

A log from the command that you were trying to run with the -vv flag

$ sftp -i ~/.ssh/id_ed25519 -P 22 my_username@10.11.8.52 -vvv
my_username@10.11.8.52's password:
Connection closed.
Connection closed
$
$ sudo rclone ls my-machine:/C:/my-data/ -vvv
2024/12/10 18:43:18 DEBUG : rclone: Version "v1.68.2" starting with parameters ["rclone" "ls" "my-machine:/C:/my-data/" "-vvv"]
2024/12/10 18:43:18 DEBUG : Creating backend with remote "my-machine:/C:/my-data/"
2024/12/10 18:43:18 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/12/10 18:43:18 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:32886->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:19 DEBUG : pacer: low level retry 1/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:19 DEBUG : pacer: Rate limited, increasing sleep to 200ms
2024/12/10 18:43:19 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:32902->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:19 DEBUG : pacer: low level retry 2/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:19 DEBUG : pacer: Rate limited, increasing sleep to 400ms
2024/12/10 18:43:19 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:32906->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:19 DEBUG : pacer: low level retry 3/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:19 DEBUG : pacer: Rate limited, increasing sleep to 800ms
2024/12/10 18:43:20 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:32910->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:20 DEBUG : pacer: low level retry 4/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:20 DEBUG : pacer: Rate limited, increasing sleep to 1.6s
2024/12/10 18:43:20 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:32920->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:21 DEBUG : pacer: low level retry 5/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:21 DEBUG : pacer: Rate limited, increasing sleep to 2s
2024/12/10 18:43:22 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:48026->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:22 DEBUG : pacer: low level retry 6/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:24 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:48034->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:24 DEBUG : pacer: low level retry 7/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:26 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:48048->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:26 DEBUG : pacer: low level retry 8/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:28 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:48052->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:28 DEBUG : pacer: low level retry 9/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:30 DEBUG : sftp://my_username@10.11.8.52:22//C:/my-data/: New connection 10.11.163.90:48054->10.11.8.52:22 to "SSH-2.0-OpenSSH_for_Windows_9.5"
2024/12/10 18:43:30 DEBUG : pacer: low level retry 10/10 (error couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF)
2024/12/10 18:43:30 CRITICAL: Failed to create file system for "my-machine:/C:/my-data/": NewFs: couldn't initialise SFTP: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF
$

welcome to the forum,

first, need to be able to access the sftp server, might try filezilla, putty or my favorite, bitvise client.
only after that is working, then try rclone.

then it should work as does this remote

rclone config redacted hetzner_sftp_powershell_tailscale:
[hetzner_sftp_powershell_tailscale]
type = sftp
host = XXX
port = 22
user = XXX
key_file = c:/data/c/combined/hetzner/keys/id_ed25519
shell_type = powershell
md5sum_command = md5sum
sha1sum_command = sha1sum
rclone lsd hetzner_sftp_powershell_tailscale: -vv
2024/12/10 19:06:43 DEBUG : rclone: Version "v1.68.2" starting with parameters ["rclone" "lsd" "hetzner_sftp_powershell_tailscale:" "-vv"]
2024/12/10 19:06:43 DEBUG : Creating backend with remote "hetzner_sftp_powershell_tailscale:"
2024/12/10 19:06:43 DEBUG : Using config file from "c:\\data\\rclone\\rclone.conf"
2024/12/10 19:06:43 DEBUG : sftp://user01@100.115.202.129:22/: New connection 100.109.123.23:55733->100.115.202.129:22 to "SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.10"
2024/12/10 19:06:44 DEBUG : sftp://user01@100.115.202.129:22/: Shell type "powershell" from config
2024/12/10 19:06:44 DEBUG : sftp://user01@100.115.202.129:22/: Relative path resolved to "/home/user01"
2024/12/10 19:06:44 DEBUG : sftp://user01@100.115.202.129:22/: Using root directory "/home/user01"
          -1 2024-04-29 09:22:57        -1 veeam
          -1 2024-12-10 19:05:55        -1 zork

I resolved this issue, it ended up being related to the SFTP subsystem configuration, either enabling an inbound rule to allow the traffic or some permissions issues. To be honest, I ran a number of commands so I'm not sure exactly which one but these are the commands I ran:

# On Windows, check firewall rules:
Get-NetFirewallRule | Where-Object { $_.Enabled -eq 'True' -and $_.Direction -eq 'Inbound' } | Format-Table Name,Enabled,Direction,Action,Profile

ls -l ~/.ssh/
# Should show permissions like:
# -rw------- (600) for private keys
# -rw-r--r-- (644) for public keys

# SFTP subsystem verification
Get-Content C:\ProgramData\ssh\sshd_config | Select-String "sftp"
Restart-Service sshd

# Authentication methods allowed on Windows sshd_config
Get-Content C:\ProgramData\ssh\sshd_config | Select-String "Authentication"

# Test basic TCP connectivity
nc -zv 10.11.8.52 22

# Test SSH connection with debug output
ssh -vvv my_username@10.11.8.52

# Check Allowed Hosts
Get-Content C:\ProgramData\ssh\sshd_config | Select-String "Allow|Deny"

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