How to open multiple SSH tunnels
March 13th, 2010
No comments
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 1.2.3.4 by opening a secure SSH tunnel between your local machine and the target address – 1.2.3.4.
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 1.2.3.4 -lmyUser -L 3098:1.2.3.4:21 -L 3099:1.2.3.4:80 -L 3100:1.2.3.4:443
The command is explained below
1.2.3.4 – 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
