Introduction

OpenSSH 4.0 and later support reusing a single SSH connection to run multiple commands. For short commands, this can be a lot faster. The new gcc.gnu.org supports this feature. You can use it to improve performance of anything run over ssh, including CVS and Subversion.

Quick guide

  1. Make sure you have OpenSSH 4.0 or newer. OpenSSH 4.2p1 is highly recommended:

  $ ssh -V
  OpenSSH_4.2p1, OpenSSL 0.9.7f 22 Mar 2005
  1. Add an entry in $HOME/.ssh/config for gcc.gnu.org if you don't already have one, and add the ControlPath option there like this:

  Host gcc.gnu.org
     ControlPath /tmp/ssh_gcc_control

  $ ssh -fMN username@gcc.gnu.org
  1. You're done! Now, all the subsequent connections to gcc.gnu.org will be much faster!

Note for old-time GCC hackers

You *must* use SSH Protocol 2 for this to work. Old GCC hackers might have only a SSH1 public key stored in gcc.gnu.org (many years ago, it used to be the only supported format), so they need to either convert their old SSH1 key with ssh-keyconverter or generate a new SSH2 key (through ssh-keygen , and send the new key to overseers@gcc.gnu.org . If you're using SSH Protocol 1, the ControlMaster option fails silently, the socket is not created, and nothing happens. All the ControlMaster =ControlPath= options are still accepted but they are ignored.

If you have an existing cvs/subversion-only account on gcc.gnu.org you can replace your key using the following command:

 $ ssh gcc.gnu.org replacekey < ~/.ssh/id_dsa.pub

To add an additional ssh key use something like the following command:

 $ ssh gcc.gnu.org appendkey < ~/.ssh/id_rsa.pub

Technical information

All you need are two things: a master connection and a multiplexing socket. The entry in $HOME/.ssh/config configures the multiplexing socket to use. Now, if the socket /tmp/ssh_HOSTNAME_USERNAME exists, it will be used instead of making a new connection (otherwise a normal connection will be made). To create the socket, you need to open a master connection. Just ssh to gcc.gnu.org using the ControlMaster (-M) option. You don't need to run a command on the remote side, so you should also use -N (no command). Another useful option is -f (fork to the background). Putting this together, this brings to the command line shown above ssh -fMN .

Note that the open connection has your authentication tokens to the remote server. If you leave the machine where you started the master SSH session, you should usually kill it.

Example measurement of the speedup

The following is a misuse of subversion, but it illustrates how the speedup comes about: subversion opens a new connection on every file given on the commandline, hence the time taken for connecting contributes significantly (again: this is not the way one would usually use subversion, cvs does this particular example much faster)

~/src/gcc_svn/gcc/fortran> time svn up *h >/dev/null

real    0m43.647s
user    0m0.290s
sys     0m0.080s
~/src/gcc_svn/gcc/fortran> ssh -M -N -f gcc.gnu.org
~/src/gcc_svn/gcc/fortran> time svn up *h >/dev/null

real    0m26.710s
user    0m0.120s
sys     0m0.060s
~/src/gcc_svn/gcc/fortran>

Platform specific notes

Unfortunately if you are using OpenSSH on Cygwin you will not be able to take advantage of connection caching because Cygwin does not currently support file descriptor passing via unix-domain sockets.

None: SSH_connection_caching (last edited 2008-05-21 00:45:45 by pool-72-74-94-32)