A ticket in the Fedora infrastructure request tracker mentioned, that one can use the control socket support of ssh to improve the speed of cvs accesses to Fedora’s cvs. In the ticket, the reporter started manually a ssh that creates a control socket and then uses it with subsequent ssh commands. These ssh commands then do not need to perform a new tcp and ssh handshake and are therefore much faster.
But there was the problem, that the because of some timeout, the socket got killed after around 30 minutes. This is of course pretty annoying. One solution is to create some traffic via the control socket every now and then to keep it open. But then one has still to open the control socket.
I did a little “investigation” and noticed that the ssh command is passed to cvs via the environment variable CVS_SSH. This makes it pretty easy to write a wrapper to first test, whether a control socket exists and to create one, if it does not. Here is what I came up with:
$ cat ~/.ssh/config
Host cvs.fedoraproject.org
ControlMaster auto
ControlPath ~/.ssh/sockets/controlsocket-%h-%p-%r
$ echo $CVS_RSH
/home/till/bin/fedora-cvs-ssh.sh
$ cat bin/fedora-cvs-ssh.sh
#! /bin/bash
SSH_USER=”${2}”
SSH_SERVER=”${3}”
/usr/bin/test -e ~/.ssh/sockets/controlsocket-${SSH_SERVER}-22-${SSH_USER} || /usr/bin/ssh -f -N -l ${SSH_USER} ${SSH_SERVER} </dev/null >/dev/null 2>/dev/null
exec /usr/bin/ssh “$@”
If you extend the ~/.ssh/config file for other hosts, it should work out of the box for every cvs over ssh access that uses port 22. If you want to use a different port, you have to edit it a little.