Step by Step: SSH Tunneling with Putty

Supposed there is server A (UNIX based), where you have firewall opened to do SSH connection from your PC directly. And there is another server (server B), where it’s connected from Server A with SSH but you have no direct SSH connection from your PC to server B (firewall is not opened from your PC to server B) .

This article will try to give tips, to make direct SSH connection possible with SSH tunneling from your PC toward server B by using Putty tool.

Note: as pre-requisite to do SSH tunneling, please set AllowTcpForwarding parameter with value equal Yes inside sshd_config fileof Server A, then restart ssh service

server-A> grep -i tcp /etc/ssh/sshd_config
AllowTcpForwarding yes
server-A> svcadm restart ssh

Method#1- Using Dynamic Port

First, connect to Server A and setup the tunnel using dynamic port

Establish SSH connection to server A using Putty. Once connected, open change settings menu (right click on top panel and choose change settings). There is category box on left side, go to Connection > SSH > then click Tunnels. Put any available local port on Source port text box (in this example, 4000 is chosen), tick Dynamic radio button, after that click Add then Apply.

Second, connect to Server B using tunnel that already set

Prepare new putty session to connect to Server B, after putting the IP and port on session part, before clicking on Open button, go to Connection > then Proxy. Tick SOCKS 5 radio button on proxy type, then on proxy hostname, fill localhost and port 4000. Click open, then now you can connect to Server B directly by using server A as proxy to make a tunnel.

Method#2- Put IP and port of another server explicitly

First, connect to Server A and setup the tunnel using specific IP and port of Server B

Establish SSH connection to server A using Putty. Once connected, open change settings menu (right click on top panel and choose change settings). There is category box on left side, go to Connection > SSH > then click Tunnels. Put any available local port on Source port text box (in this example, 4001 is chosen). And on Destination, fill explicitly the IP and port of server B with format IP:port, in this example, value is 10.10.10.10:22), tick Local radio button, after that click Add then Apply.

Second, connect to Server B using tunnel that already set

Prepare new putty session to connect to Server B, on Hostname (or IP address), fill with localhost and port, is 4001. Click open, then connection to Server B can be done directly.

Advertisements

1 thought on “Step by Step: SSH Tunneling with Putty”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s