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.
The command would then look like:
ssh -L 10001:one.securedomain.com:3389 -L 10002:two.securedomain.com:3389 firstname.lastname@example.org Hope this helps someone else out!