Yes, see the ControlMaster and ControlPath options.
You can start the master connection with:
mkdir ~/.ssh/ctl
ssh -nNf -o ControlMaster=yes -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" user@host
And then use rsync with:
rsync -e "ssh -o 'ControlPath=$HOME/.ssh/ctl/%L-%r@%h:%p'" ...
Then
ssh -O exit -o ControlPath="$HOME/.ssh/ctl/%L-%r@%h:%p" user@host
to terminate the master connection.
(And by the way, some versions of ubuntu have an annoying feature in that they rebuild /etc/motd upon every login (including non-interactive ssh sessions), which can take a long time if part of that involves checking if updates are available for instance. IIRC, you can disable it by removing pam_motd from your pam configuration)
It should be noted that OpenSSH client also supports the -M
command-line option whith the same meaning as -o ControlMaster=yes
and the -S <path>
command-line option with the same meaning as -o ControlPath=<path>
. At least this is the case with OpenSSH 5.1p1.