Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create SSH tunnel using PuTTY in Windows?

I need to create SSH tunnel with PuTTY in Windows, that would do the same as this command in Linux:

ssh -fN -L 2000:SomeIp:2000 myusername@myLinuxBox 

I tried many options in PuTTY, including setting source port in GUI to "2000" and destination to "SomeIp:2000". Destination is set to local (as the -L switch suggests).

I successfully login to my SSH box but port forward is not made.

Is this even possible in Windows, so that all the connections made by programs that use this port (2000) will go through this tunnel?

like image 928
DixieFlatline Avatar asked Feb 11 '11 21:02

DixieFlatline


People also ask

How does SSH tunnel work in PuTTY?

SSH tunneling, or SSH port forwarding, is a method of transporting arbitrary data over an encrypted SSH connection. SSH tunnels allow connections made to a local port (that is, to a port on your own desktop) to be forwarded to a remote machine via a secure channel.

Can I use PuTTY to SSH?

PuTTY is a free software application for Windows 95, 98, XP, Vista, 7, 8, ad 10 which can be used to make an SSH connection to your server.

How do I setup port forwarding in PuTTY?

Click on the small icon in the upper left corner to access the Putty Menu, then click on Change Settings... Enter port number as the Source port and host:port as the Destination, then click Add. Check both boxes at the top: Local ports accept connections... and Remote ports do the same...


2 Answers

With the PuTTY suite, you can set up a tunnel either using the PuTTY itself (GUI) or using the command-line tool plink.exe.


With the plink.exe, you use the same arguments as with the OpenSSH ssh, except for the -f, which does not have an equivalent in Windows.

plink.exe -N -L 2000:SomeIp:2000 myusername@myLinuxBox 

Reference: Using the command-line connection tool Plink


With the PuTTY, the -L 2000:SomeIp:2000 translates to:

PuTTY tunnel settings

So it's actually, what you claim to have tried. If you have any problems, use the PuTTY event log to investigate:

PuTTY event log

The -N translates to the option "Don't start a shell or command at all".

PuTTY option Don't start a shell or command at all

But it probably does not make sense with a GUI client to enable it, as you get a window anyway, you just cannot do anything with it. See also the PuTTY wish no-terminal-window.


If you are going to use the tunnel to connect with PuTTY to another server, you can actually set up the tunnel as a part of the session settings with use of plink as a proxy, see: PuTTY configuration equivalent to OpenSSH ProxyCommand.

like image 151
Martin Prikryl Avatar answered Sep 20 '22 01:09

Martin Prikryl


You probably want to use plink.exe instead of the GUI client. The command line syntax is compatible iirc.

like image 45
Barend Avatar answered Sep 20 '22 01:09

Barend