Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thiagoguarnieri/8ede26bebd23944d63befbb0696b65c7 to your computer and use it in GitHub Desktop.
Save thiagoguarnieri/8ede26bebd23944d63befbb0696b65c7 to your computer and use it in GitHub Desktop.
Using rsync to transfer a file from/to a server using two hop SSH
# Command used to send a file to a remote server B only reachable through a remote server A
# Local <----> A <----> B
# receive
rsync -av --append -e 'ssh -o "ProxyCommand ssh user@server_A exec nc %h %p 2>/dev/null"' user@server_B:/path/source.file destination.file
# send
rsync -av --append -e 'ssh -o "ProxyCommand ssh user@server_A exec nc %h %p 2>/dev/null"' destination.file user@server_B:/path/source.file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment