If you are make multiple connections to the same server, you can enables the sharing of multiple sessions over a single network connections. In other words, the additional sessions will try to reuse the master instance's connection rather than initiating new ones.
Step 1: Create a config file in your ~/.ssh directory. Make sure the permission is readable and writable by the owner only ie permission of 600
Step 2: Add the following lines
Host * ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%pControlMaster auto Tries to start a master if there is no existing connection or it will use an existing master connection. ControlPath is the location 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.
Step 3a: To test the configuration, start an ssh session and keep it connected, you should see something like
........... debug1: setting up multiplex master socket debug1: channel 0: new [client-session] ...........
Step 3b: Launch another ssh connection to a the same server with the same userid
.................... debug1: auto-mux: Trying existing master ...................
Much of the materials come from Speed Up Multiple SSH Connections to the Same Server (Linux Journal).
No comments:
Post a Comment