Skip to main content
fixed formating according to convention
Source Link
Archemar
  • 32.3k
  • 18
  • 75
  • 107

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'

    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

    $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/

    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

    $master_ssh -O exit $remote
    

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

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
    
Source Link
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