Alex Urquhart
Geomatics Professional

SSH Port Forwarding Made Easy

Tags: linux openSSH tunneling port forwarding

Have you ever wanted to access a resource on a remote server from your home computer?

The standard ssh utility includes a feature called tunneling, or ssh port forwarding that can help you accomplish this. It’s a useful tool if you want to connect to a remote e-mail server, database, or application server.

Personally, whenever I’ve wanted to do this I always end up googling the flags and parameters I need to use. Since I figured I’m not the only one with this problem I decided to create this simple tool to generate a command for you to paste into your console.

Input Parameters

Output Command

Copy To Clipboard

Explaination

$> ssh -f [email protected] -L 2000:localhost:25 -N
  • -f Requests ssh to go to background just before command execution.
  • [email protected] Username and address of the remote server.
  • -L 2000:localhost:25 Specifies that the given port on localhost is to be forwarded to the given host and port on the remote side. In this case port 2000 on the local machine will be securely tunneled to port 25 on the remote machine.
  • -N Do not execute a command on the remote machine.

Once executed the remote session will be in the background. You can exit the session using a combination of ps aux | grep ssh to find the process ID and kill to end the process.

For more information see the ssh man pages.

comments powered by Disqus