Permanent SSH Tunnel

Problem

You need a SSH tunnel to another machine which is still alive after you close the bash or the Putty window.

Solution

The command to solve the problem:

ssh -fN  -L 1234:destination_server:4321 username@server

Explanation

  • -f: Force ssh to go to background before one command is executed, but it will display the password prompt.
  • -N: Tell ssh not to execute a command (-f would require one command)
  • -L: Open a tunnel from the local port 1234 to a destination server with the port 4321.
Advertisements

One thought on “Permanent SSH Tunnel

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s