How to create an SSH tunnel with Putty / Kitty

An SSH tunnel is a tunnel created over an SSH connection and used to encrypt tunneled data. Used to secure data transmission on the Internet.

Tunnel setup

Launch Putty / Kitty

In the Host Name field, enter the IP address of the server to which we will connect, in the Port field, enter the ssh port (by default, 22)

How to create an SSH tunnel with Putty / Kitty 2

Go to the left menu in the SSH section – Tunneles

In the Source port field, enter the local port, which we will subsequently refer to (22)

In the Destination field, enter the destination address to which you will connect, in the ip: port format and click Add

How to create an SSH tunnel with Putty / Kitty 3

For instance:

  • If we want to forward the local (source) ssh-port (22) to the remote (destination) 22, then Source port = 22, Destination =% your_ip%: 22 (substitute your ip)
  • If we want to forward the local (source) mysql port (3306) to the remote (destination) 3306, then Source port = 3306, Destination =% your_ip%: 3306 (substitute your ip)
  • If we want to forward the local (source) postgresql port (5432) to the remote (destination) 5432, then Source port = 5432, Destination =% your_ip%: 5432 (substitute your ip)

How to create an SSH tunnel with Putty / Kitty 4

In order not to enter this data each time, go to the Session section in the left menu, enter a convenient record name in the Saved Session field and click Save

How to create an SSH tunnel with Putty / Kitty 5

To load this data next time: run Putty / Kitty, select the line, and click Load

In order to connect via SSH and to establish our tunnel, press the Open button

How to create an SSH tunnel with Putty / Kitty 6

A terminal will open, where the system will ask you to enter your username / password (the password is not displayed when typing)

On successful connection, you will see something like this

How to create an SSH tunnel with Putty / Kitty 7

Tunnel check

We establish an SSH connection, run the command line and check the port availability via telnet

How to create an SSH tunnel with Putty / Kitty 8

The server should respond

How to create an SSH tunnel with Putty / Kitty 9

Sidebar