In my company we access our remote electronic devices through a jump server. When we need to download files from the devices we do the following:

  1. ssh jump.server.com
  2. wget ftp//device_ip/filepath (this downloads the file to the jump server)
  3. scp the jump server from local machine to get the file.

I am trying to simplify this by using ssh port forwarding to be able to download the file directly from the remote devices to our machine. I followed this answer:

ssh -L 9000:device_ip:21 jump.server.com
wget ftp://localhost:9000/filepath

But I am getting the following error:

227 Entering Passive Mode (10,192,1,16,19,129).
trying to connect to port 4993
Closed fd 4
Closed fd 3
couldn't connect to ipaddress port 4993: Connection timed out
Giving up.

The issue is not the passive mode that wget uses because it works when using the old method.

Any suggestions in what could be causing the problem? Our computers run Ubuntu if that helps.


FTP uses port 21 for the control connection but then needs for the actual data transfers additional connections using different, dynamically agreed on, ports. This makes it impossible to simply tunnel FTP through a single TCP connection, no matter if active or passive mode.

If your FTP client supports the SOCKS protocol you might try to setup ssh as SOCKS server with the -D option and then use it with FTP passive mode.

Another option would be not to login, get the file and transfer it back, but to do all at once:

$ ssh user@remote wget -O - ftp://host/file > file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.