Verfasst von: hugahaga | 8 April 2010

How to open multiple SSH tunnels – CertPal

I use remote linux services often and exposing them as local services can be performed securely using SSH. For example you can access a tomcat server or email server hosted at IP by opening a secure SSH tunnel between your local machine and the target address –

The OpenSSH tool can be used to perform SSH related activities on your machine. Simply install it with yum, apt-get or Yast, if it is not already available. Once you have it use the following command to open multiple SSH tunnels to your services

Open tunnel and execute commands:

ssh -lmyUser -L 3098: -L 3099: -L 3100:

The command is explained below – Your target IP

l – The user to login as

L – A local tunnel to a remote port

3098 – The local port to use when establishing this tunnel

21 – The remote port at to which the tunnel will be established

Multiple tunnels can be opened by specifying multiple -L flags. For example http://localhost:3099 will now redirect to That is a fancy way of saying all HTTP requests ( 80 is the default port ) for can now be reached locally at port 3099.

Note that the above command will also log you into the remote system. If you want to open the tunnels alone, use the -N switch and the -f switch as shown below

Open tunnels only:

ssh -f myUser@ -L 3099: -N

The -f switch asks SSH to work in the background and -N asks SSH not to execute any commands.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s


%d Bloggern gefällt das: