SFTP download behind firewall:
From openSUSE
HowTo:Download files via SFTP (Secure File Transfer Program) when your SSH server is behind a firewall
Author: G0NZ0
Linux Version: Any
NOTICE: this is complementary to: [Upload files via SCP (Secure Copy Program) when your SSH server is behind a firewall]
Requirements:
1) It is hereby assumed that your remote machine runs a unix and on it SSHD is enabled (to check: type the command /etc/init.d/sshd status , to start or stop: /etc/init.d/sshd start or /etc/init.d/sshd stop). We will call your firewalled machine my_host and let's suppose that username is a user on it.
2) There must be a "visible" machine which lets you login through SSH. Let's call it visiblehost.ac.uk. In other words you have an account on it, say visible_username
- Problem 1: You want to connect via SSH to a remote machine which is behind a firewall
This is other than SFTP. However since this commands are needed for SFTP as well, I will report them here.
First you have to login into the visible machine:
ssh -X visible_username@visiblehost.ac.uk
Then you have to login into your firewalled machine:
ssh -X username@my_host
Now from here you can start applications also with GUI. For example typing thunderbird you will see on your local machine thunderbird running, even if you don't have thunderbird installed locally! You just need to have a compatible OS (if you're on Windows, it won't work)
- Problem 2: You want to connect via SFTP to a remote machine which is behind a firewall in order to transfer files
Since you cannot SFTP your firewalled machine directly, you ill need first to SSH on visiblehost.ac.uk. You will have to do a double SFTP but once you are on visiblehost.ac.uk you cannot reach my_host. Thus SSH is needed before SFTP
First you have to login in SSH into the visible machine:
ssh -X visible_username@visiblehost.ac.uk
Then you have to login in SFTP into your firewalled machine:
sftp username@my_host
Ok, almost done: now you can get any files you want.
get whatever_you_want
Be careful: now these files will go in your account on visiblehost.ac.uk !! You were connected in SSH to it, not in SFTP, so now you need to start a SFTP session directly on it in order to get the files:
sftp visible_username@visiblehost.ac.uk get whatever_you_want
Finally you will have those files on your own local computer (in home, since we didn't specify more options in SFTP). No matter if your local machine is firewalled, since it is you that are starting the connection.
To terminate either a SSH session or a SFTP session, type exit.

