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?
You probably want to use
plink.exe
instead of the GUI client. The command line syntax is compatible iirc."Source" port is a port number on the same machine from which you are running putty (eg. open this in your browser: 127.0.0.1:source). "Destination" is your remote port that you want to connect to from your local machine. It started to work after I realized this.
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 OpenSSHssh
, except for the-f
, which does not have an equivalent in Windows.Reference: Using the command-line connection tool Plink
With the PuTTY, the
-L 2000:SomeIp:2000
translates to:So it's actually, what you claim to have tried. If you have any problems, use the PuTTY event log to investigate:
The
-N
translates to the 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.
Or you can wade through the putty GUI, which also allows this. See
Connection > SSH > Tunnels
on the left side with the option tree.The answers above mention two different ways of resolving the problem:
I don't have plink and I can't download the plink.exe file (it is a closely monitored restricted environment) so used a different way to script the solution with a one-line script:
Store this in a batch file (file extension ".bat", e.g. "tunnel.bat"). So every time you double-click on this file the command is run and putty creates the ssh tunnel. If you want more tunnels just repeat this part
by changing the ports accordingly.