Cannot connect to ftp over socks proxy with rclone but can connect with curl

What is the problem you are having with rclone?

I have a FTP at my hosting company but it is only accessible from a specific ip address. I would like to access this ftp from my laptop over a socks proxy.

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

rclone v1.65.1
- os/version: debian 12.4 (64 bit)
- os/kernel: 5.15.90.1-microsoft-standard-WSL2 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.21.5
- go/linking: static
- go/tags: none

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

Plain FTP.

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

rclone lsf :ftp: --ftp-host=backup-ftp.example.com --ftp-user=myftpuser --ftp-pass=MY_HASHED_PASSWORD --ftp-socks-proxy 127.0.0.1:1080

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

2024/01/22 07:32:17 NOTICE: Config file "/home/wiktor/.config/rclone/rclone.conf" not found - using defaults
; empty config
### Double check the config for sensitive info before posting publicly

I don't use a config, I try to run the command where everything is specified exactly.

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

2024/01/22 07:33:42 DEBUG : rclone: Version "v1.65.1" starting with parameters ["rclone" "lsf" ":ftp:" "--ftp-host=backup-ftp.example.com" "--ftp-user=myftpuser" "--ftp-pass=MY_HASHED_PASSWORD" "--ftp-socks-proxy" "127.0.0.1:1080" "-vv"]
2024/01/22 07:33:42 DEBUG : Creating backend with remote ":ftp:"
2024/01/22 07:33:42 NOTICE: Config file "/home/wiktor/.config/rclone/rclone.conf" not found - using defaults
2024/01/22 07:33:42 DEBUG : :ftp: detected overridden config - adding "{udq62}" suffix to name
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: Connecting to FTP server
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: dial("tcp","backup-ftp.example.com:21")
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: > dial: conn=*fshttp.timeoutConn, err=<nil>
2024/01/22 07:33:42 DEBUG : fs cache: renaming cache item ":ftp:" to be canonical ":ftp{udq62}:"
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: dial("tcp","127.0.0.1:59957")
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: > dial: conn=<nil>, err=socks connect tcp 127.0.0.1:1080->127.0.0.1:59957: EOF
2024/01/22 07:33:42 ERROR : : error listing: socks connect tcp 127.0.0.1:1080->127.0.0.1:59957: EOF
2024/01/22 07:33:42 DEBUG : 4 go routines active
2024/01/22 07:33:42 DEBUG : ftp://backup-ftp.example.com:21: closing 1 unused connections
2024/01/22 07:33:42 Failed to lsf with 2 errors: last error was: error in ListJSON: socks connect tcp 127.0.0.1:1080->127.0.0.1:59957: EOF

Before running this command I connect to my host over ssh and open the socks proxy over the specified 1080 port.

I catch this error in the windows of ssh:

channel 4: open failed: connect failed: Connection refused

I suppose this curl command is equivalent with this rclone command and this works perfectly.

curl -v ftp://backup-ftp.example.com --user myftpuser:PASSWORD --ftp-pasv --socks5 127.0.0.1:1080

I tried to debug the ssh connection:

This is the ssh debug when I run the curl command

[devel@abenaki ~]$ debug1: Connection to port 1080 forwarding to socks port 0 requested.

debug1: channel 3: new dynamic-tcpip [dynamic-tcpip] (inactive timeout: 0)

debug1: Connection to port 1080 forwarding to socks port 0 requested.

debug1: channel 4: new dynamic-tcpip [dynamic-tcpip] (inactive timeout: 0)

debug1: channel 4: free: direct-tcpip: listening port 1080 for 212.52.yyy.zzz port 57686, connect from 127.0.0.1 port 35258 to 127.0.0.1 port 1080, nchannels 5

debug1: channel 3: free: direct-tcpip: listening port 1080 for 212.52.yyy.zzz port 21, connect from 127.0.0.1 port 35244 to 127.0.0.1 port 1080, nchannels 4

And this is the debug when I run rclone:

debug1: Connection to port 1080 forwarding to socks port 0 requested.

debug1: channel 3: new dynamic-tcpip [dynamic-tcpip] (inactive timeout: 0)

debug1: Connection to port 1080 forwarding to socks port 0 requested.

debug1: channel 4: new dynamic-tcpip [dynamic-tcpip] (inactive timeout: 0)

channel 4: open failed: connect failed: Connection refused
debug1: channel 4: free: direct-tcpip: listening port 1080 for 127.0.0.1 port 59397, connect from 127.0.0.1 port 51670 to 127.0.0.1 port 1080, nchannels 5

debug1: channel 3: free: direct-tcpip: listening port 1080 for backup-ftp.example.com port 21, connect from 127.0.0.1 port 51654 to 127.0.0.1 port 1080, nchannels 4

I have limited understanding of ssh and proxy but I see when curl request the connection, there is the proper external ip address for the ftp. But when rclone there is only the local 127.0.0.1.

I tried to command with plain ip address to remove possible dns problem, but this does s not work either.

As far as I know passive mode is the only mode which supported by rclone, so this can't be an issue.

I know it is a very complicated problem without an easy reproducible script but I think the curl and the rclone command should be equivalent in my scenario and in this way this could be check with any ftp.

Any help would be greatly appreciated.

Thank you.

Wiktor

can you post the command that worked?

Sure! This curl command works perfectly.

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