Contents[Hide]

SSH Port Forwarding allows us to create a very simple "VPN" which lets you to secure insecure protocols such us telnet or ftp. When creating encrypted ssh connections a client needs to be connected to a ssh server on a remote host, thus creating a ssh tunnel via which an insecure information will travel. In this scenario, we are going to use ssh port forwarding to create an encrypted tunnel for telnet connection.

1. Enable telnet server on remote host

Let us first confirm that the telnet server is running on a remote host:

$ netstat -ant | grep 23 

remote server port 23

2. Create ssh tunnel to remote host

In this example you will open port 4500 on your local host and tunnel it to the port 23 on your remote host. You do not have to do this as a root. Since we are using a port higher than 1024 a ordinary user is able to create this port forward connection. Keep in mind that a tunnel is erected only when the ssh connection is running.

# ssh -L 4500:127.0.0.1:23 linuxconfig.org 

create tunnel
At this point, every connection which uses port 4500 on the localhost will be redirected to remote port 23.

3. Telnet to remote host via ssh port forwarding

Before we attempt to telnet to a remote host via tunnel, we need to ensure that the tunnel is still running:

# netstat -ant | grep 4500 

ssh port forwarding
Once we know that the tunnel is still running we can attempt to telnet on local port 4500.

# telnet localhost 4500 

Telnet to remote host via ssh port forwarding



Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top