Have you ever wanted to access a resource on a remote server from your home computer?
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.
$> ssh -f firstname.lastname@example.org -L 2000:localhost:25 -N
-fRequests ssh to go to background just before command execution.
email@example.comUsername and address of the remote server.
-L 2000:localhost:25Specifies 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.
-NDo 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.