I use SSH to work on my servers from home. I don't like typing my password every time I need to open a new SSH connection. Unfortunately, I'm too paranoid to set up the passwordless public and private keys. That's where the ControlMaster and ControlPath options come into play in SSH.
`man ssh_config` for more details, but here's a summary. ControlMaster gives the user the ability to share multiple SSH sessions over a single network connection. This means I no longer have to enter my password twice. The initial connection opened to serverA creates a socket, specified by ControlPath, and then listens on that socket for connections.
When another SSH session is opened to serverA, the user does not specify the ControlMaster command line option, but does specify the control socket it should attempt to use. If the ControlMaster connection is gone, the second connection will forge a new link as usual with no errors.
Here's an example. Open the master connection first:
`ssh serverA -M -S /tmp/%r@%h%p`
Check ssh_config's man page for details on what those options mean. Your connection will occur normally, you will hardly notice a difference beyond the file in /tmp. Now open your second connection:
`ssh serverA -S /tmp/%r@%h%p`
Hey! No password needed. According to OpenSSH, you're already authenticated on the remote server.
What does this do to X11 and ssh-agent forwarding? According to the man page: "the display and agent forwarded will be the one belonging to the master connection i.e. it is not possible to forward multiple displays or agents."
If the master connection is dropped before the other connections, I've noticed that the terminal window holding the master connection won't drop back to the local shell. If the terminal window is forced to close, the other connections are destroyed as well with the error "Connection to master closed.".