Linux Blog

Forwarding Ports over an active SSH connection

Filed under: General Linux,Linux Software,Quick Linux Tutorials — at 12:01 am on Tuesday, October 7, 2008

There is no doubt about it that SSH is a handy administration and remote access tool. Have you ever wanted to add port forwarding or cancel port forwarding from within an active SSH connection? Well, a feature that many do not know about is the ssh escape feature. With this pseudo terminal you can do some nifty things, such as forward ports over an active SSH connection.

To do this, follow these instructions:
(Read on …)

SSH Tunnel

Filed under: Linux Software,Quick Linux Tutorials — at 11:23 pm on Thursday, March 6, 2008

Today I had the need to access my development web server at my office network. I have a firewall that runs SSH but doesn’t my firewall does not forward the port for the web server. So, in an emergency situation I was able to use an Linux with SSH and Tunnel into my network on port 80. Since I have a server running on port 80 on this computer I could not use this port. I chose port 8080 to use for the local port and forward it to my web server on the firewalled network. I did this by doing the following:

ssh <SSH HOST> -L 8080:192.168.1.X:80

Using SSH Tunneling I was able to then browse to http://localhost:8080 on this computer and successfully view the contents of my web server. So, any time you need to connect to a port on a computer behind a NAT firewall that you have access to SSH on is just use a SSH Tunnel and then use the -L Switch with the port on your local machine first, then the destination address and port. Simple!