ssh connection sharing

by

ControlMaster and ControlPath are the ssh config options you are looking to use here.  You'll want to add them to your ssh config file, which is located in

~/.ssh/config

You simply want to add the following lines to your config file.

Host *ControlMaster autoControlPath ~/.ssh/control_%r@%h:%p

The Host command tells ssh that everything that follows are rules for whatever host is defined.  In this case, the asterisk tells ssh that all hosts should use the conditions present.  ControlMaster enables the sharing of multiple sessions over a single network connection.  ControlPath defines the location the socket connections should be located.  In this case, we are placing them in ~/.ssh/.  %r is token for remote user login, %h is for the host, and %p is the port.  You'll basically have files that look like this:

~/.ssh/control_username@example.com:22