Back to the grind – SSH Multiplexing – say wha?????
So, It’s been quite a while since I posted anything on this blog. Thought I would get back into the swing of things. I have tons of updates but lately very little time. I think I’ll try to dedicate at least an hour a week to get something up here if not more.
For now, thought I would add to the latest linux tips n tricks I use to post.
I knew about this for quite a while but never really used it, lately for the past few months it’s been a life saver. On avg during the course of my workday, I’m accessing 5-10 systems. This results to an ugly infestation of terminal windows, which surprisingly I have mastered the art of organizing thanks to tmux.
Anyways, what this allows you to do is use 1 TCP connection for each server you connect into. Any additional SSH requests created from your client will use existing connection already established. Cutting your login time in half.
Modify your existing ~/.ssh/config file and add the following:
Host * ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto tells ssh to try to start a master if none is running, or to use an existing master otherwise. ControlPath is the location of a socket for the ssh processes to communicate among themselves. The %r, %h and %p are replaced with your user name, the host to which you’re connecting and the port number—only ssh sessions from the same user to the same host on the same port can or should share a TCP connection, so each group of multiplexed ssh processes needs a separate socket.
To test this, initiate a single ssh connection to any server. In a new window create another ssh connection to the same server. You should immediately see a difference the 2nd time around.
I would like to thank the Linux Journal for this cool tip, I had a 5 year old bookmark that I stumbled over a few months back that got me hooked. You can find it Here
For now, I’m off, check back later.