WinSCP – Tunnel in Tunnel

The situation:

When you must to use jump-servers & you don’t like to use scp command instead of using (Windows / Norton / Volcov / Total commander like) WinSCP with tunneling.

 

schematic

The path:

You (Mr. iT) would like to copy your log file from the Target Server (T) to your local computer. You can use simply scp with the correct syntax, or SSH-tunnel with PuTTY OR WinSCP.

WinSCP (for me) have more advantages:

  • Clear, common UI (like commanders)
  • Two panel. More effective
  • Save credentials & path (you adjust it once then save it)
  • Portable options (export from WinSCP)

So the path is: FROM Your Local Computer TO Jump A then TO Jump D and in the end, TO Target Server (T).


Solution with WinSCP:

WinSCP have possibility to use & create tunnel with local port creation. We will use this feature:

You create a new connection with the following settings:1

Host name: Jump “D”. For example: “141.11.25.12”.

User name: Mr. iT. What you use for SSH to Jump “D”.

Password: ******. What you use for SSH to Jump “D”.

Click on “Advanced” button

 Create tunnel for this new connection:2

In left panel choose “Tunnel” option.

Enable “Connect through SSH tunnel” option

Host name: Jump “A”. For example: “38.1.25.11”

Port number: If your SSH is listening on different port, please adjust port number.

– User name: Mr. iT. What you use for SSH to Jump “A”.

Password: ******. What you use for SSH to Jump “A”.

Local tunnel port: This port will be used on your local computer to reach the target server. So choose one and note it (hint – better if you add choose port to your connection’s name like – “cellar_sytem-50000”)

Private key file: If you need private key for authentication in Jump “A” please browse it in here.

Now you have WinSCP connection FROM your local computer TO Jump “D”. Start to work on

Second part of create tunnel to Target Server (T): Create an another one new connection

3

Host name: Target Server (T). For example: “192.168.1.45”.

User name: Mr. iT. What you use for SSH to Target Server (T).

Password: ******. What you use for SSH to Target Server (T).

Click on “Advanced” button

4

In left panel choose “Tunnel” option.

Enable “Connect through SSH tunnel” option

Host name:  localhost. This must be localhost as we now define previously created tunnel.

Port number: Your local computer’s port where previously connection was assigned. In our example: 50000

– User name: Mr. iT. What you use for SSH to Jump “D”.

Password: ******. What you use for SSH to Jump “D”.

Local tunnel port: If this tunnel will be NOT forwarded, this option is not important.

Private key file: If you need private key for authentication in Jump “D” please browse it in here.

Now you have connection to the Target Server (T). because these connections are embedded into each other you most to open it sequentially.

First open the firstly created connection, because this will create forwarded port to you localhost (Your Local Computer). In our example: localhost:50000.

After it open the last created connection. If you close the first connection, your second connection will also will be interrupted.

That all. Of course if you have longer path / chain this logic can be used. I hope I could help to you.

Best Regards

Leave a Reply