Skip to main content
1 of 2
JohnA
  • 131
  • 1

It took a while to get this to work, see here for a full example and explanations.

In short you need to:

  1. create an ssh config file that hold information about the ssh session

    remote=your_ip_address echo "HostName $remote" > ssh_config echo "User root" >> ssh_config echo "ControlMaster auto" >> ssh_config echo "ControlPath ~/.ssh/%C" >> ssh_config master_ssh='ssh -F ssh_config'

  2. start the master session

    $master_ssh -MNf $remote

  3. do the rsyncs

    rsync -e "$master_ssh" $opts $remote:/etc/some_file1 local_directory/ rsync -e "$master_ssh" $opts $remote:/etc/some_file2 local_directory/ rsync -e "$master_ssh" $opts $remote:/etc/some_file3 local_directory/

  4. close the master session

    $master_ssh -O exit $remote

JohnA
  • 131
  • 1