Mon 28 January 2019

When you need to open multiple connections to an ssh host where you don't have key authentication you can avoid to digit the password every time using only one connection for all sessions.

Connect first to remote host activating Control Master and specifying the socket to use for subsequent connections:

ssh -M -S ~/.ssh/<socket> <host>

Then open other connections using the socket, you don't be asked for the password:

ssh -S ~/.ssh/<socket> <host>

If you need to open an independent connection specify a null socket:

ssh -S none <host>

If you want to make this behaviour persistent, add these lines to your ~/.ssh/config (make sure to understand and adapt them to your needs):

Host <host>
ControlMaster auto
ControlPath ~/.ssh/cm_socket-%r@%h:%p
ControlPersist 1

Here are the parameter description as in the manual page:

ControlMaster auto
try to use a master connection but fall back to creating a new one if one does not already exist.
ControlPath ~/.ssh/cm_socket-%r@%h:%p
Specify the path to the control socket used for connection sharing
ControlPersist 1
specifies that the master connection should remain open in the background (waiting for future client connections) after the initial client connection has been closed.