SSH Connection Sharing

I was reading a post on a perl blog the other day and leaned about connection sharing in ssh. It allows you to open a ssh connection to a server and while that 1st connection is open, all subsequent connections will use the 1st connections credentials. It really saves time not having to enter your password if you are not using ssh keys. To enable it all you have to do is add the following two lines to your ~/.ssh/config file. If you do not have a config, just create it and add the two lines to the new file.

ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r

Another cool tip is that you can keep your connection ready for a specified period of time, even if you log out. So, if you log into the same server several times a day, you will only have to provide a password the 1st time until an inactive period of time passes. Add the the following to your ~/.ssh/config to keep connections ready for 2 hours.

ControlPersist 2h

The site I got this info from is here.

This entry was posted in Linux, Sysadmin. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.