For reasons I won’t go into I often have to set up multiple SSH tunnels to a remote box — often enough that it would be nice to be able to initiate it with a single command from a desktop launcher (I use GNOME Do).
Currently I have .ssh/config set up with the following (snipped a little and anonymised):
Host hawkeye Hostname hawkeye.avengers.com Port 22 User thedudeabides IdentityFile ~/.ssh/id_rsa LocalForward 8888 webproxy.avengers.com:888 LocalForward 4845 irc.avengers.com:7434 LocalForward 4093 git.avengers.com:3329
..and I open a terminal and run ‘ssh hawkeye’, which sets up tunnelling and leaves me ssh’d into hawkeye.
Problem is (small problem, granted) is that I often don’t want the remote console session opened, and I’d like to be able to set these tunnels up with a single command from GNOME Do, so the tunnels are set up and backgrounded, but no terminal is opened.
I’ve tried scripts using various SSH flags but it never works as intended.
Any help appreciated.
ssh -N hawkeye, as specified in the man page:
-N Do not execute a remote command. This is useful for just for‐ warding ports (protocol version 2 only).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.