Multiple SSH Tunnels
This week I needed to set up connections to 4 different Windows servers, each hosted at the same hosting provider. They will be running different components of one application, so I’ll probably be accessing all of them at once. Simple enough, except that in order to connect to the servers I need to access the hardware VPN that is located in our office on the other side of the country!
I knew that I needed to set up a SSH tunnel from my laptop (a MacBook) to the servers, but I certainly did not want to open 4 different shells each time I wanted to connect to all the servers. Each of the 4 tunnels needs to pass through the same server located within the firewall at our office.
Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command. The command to do this is: ssh -L :: -L :: @ So, say that I wanted to set up local ports 10001 and 10002 to connect to a couple of servers at securedomain.com and tunnel through trusteddomain.com.
he command would then look like: ssh -L 10001:one.securedomain.com:3389 -L 10002:two.securedomain.com:3389 steve@tunnel.trusteddomain.com Hope this helps someone else out!


Comments
Sure does!
Thats Steve, yes that is useful to me. Thanks for sharing and keeping it real! :0)
Tunnel multiple ports with one command
When tunneling a port through ssh, sometimes one port is not enough. Meaning, I need to be able to tunnel a few specific ports (i.e. 80, 514, 8080) or a range (10000 to 20000).
How would either of these be possible?
Thanks in advance.
reverse-tunnel multiple ports
I am reverse-tunneling multiple prots, but it does not work:
ssh -T -R 30065:localhost:30065 -R 5900:localhost:5900 -p 30064 xxx.xxx.xxx.xxx
I cannot get the two desired connections at the same time (one is VNC, the other is sftp?) authentication issues comeup like: fingerprint has changed or something like that, when I try initiate the 2nd service. any help appreciated
Post new comment