How to download a file through (Putty) SSH

puttywinscp

Imagine the following situation:

I do not have direct SSH access to Server-A due to IP filtering restrictions. To access the server (from windows using putty), I first connect to Server-B, which has a white listed IP address, and from there SSH into Server-C, and then SSH from there to Server-A (I know that sounds insane, but unfortunately I do not have rights to change the IP filtering restrictions). Is there a way using putty/winscp/anything else to download a file from Server-A to my local PC?

Best Answer

Use port forwarding. WinSCP, for example, has an option to create a connection through a ssh tunnel and it uses port forwarding. Still, since you need to tunnel through two hops, you cannot use it.

I would propably first create a ssh connection to server-B which has a tunnel to server-C. You could use plink.exe for this (part of putty):

plink.exe -l username_on_server_B -L 8888:server-C:22 server-B

Now you can create a second tunnel, using a ssh connection to server-B, which leads to server-A (in a second cmd.exe shell):

plink.exe -l username_on_server_C -L 8889:server-A:22 -P 8888 localhost

After this, you should be able to connect to server-A using WinSCP. Instead of server-A, you connect to localhost port 8889, which will be tunneled to server-A.

This is untested but it should work I think.