Skip to content

Instantly share code, notes, and snippets.

@dfang
Forked from lgloege/rsync_from_server.md
Last active January 1, 2020 07:08
Show Gist options
  • Save dfang/e41b1dc845ed5fb4964a59a808c116b9 to your computer and use it in GitHub Desktop.
Save dfang/e41b1dc845ed5fb4964a59a808c116b9 to your computer and use it in GitHub Desktop.
Use rsync to copy from a server with bastion server between them. Does not require scp or ssh tunneling.

Setup keyless login

  1. On local make an RSA key if you haven't already (ssh-keygen)
  2. Copy that key into .ssh/authorized_keys on the first (i.e. bastion) server (ssh-copy-id user@bastion.server) 2b. Test that you can ssh user@bastion.server and connect without password
  3. ssh to bastion.server and create an RSA key on bastion.server if you haven't already (ssh-keygen)
  4. ssh-copy-id to the server you want to access (what I am calling real.server) 4b. test that you can ssh from bastion.server to real.server without entering a password

To copy from server to local

rsync -e "ssh user@bastion.server ssh" user@real.server:/path/to/file /path/to/local/dest

To copy from local to server

rsync -e "ssh user@bastion.server ssh" /path/to/local/src user@real.server:/path/to/server/dest

@dfang
Copy link
Author

dfang commented Jan 1, 2020

-e, --rsh=COMMAND           specify the remote shell to use

-e "ssh user@first.server ssh" means use bastion's ssh as remote shell

@dfang
Copy link
Author

dfang commented Jan 1, 2020

use sz/rz to sync files between the server and local laptop

https://github.com/aurora/iterm2-zmodem

https://github.com/aikuyun/iterm2-zmodem

local to server

  1. ssh login to server
  2. rz
  3. select files
  4. wait

server to local

  1. ssh login to server
  2. sz file1 ......
  3. select destination folder
  4. wait

between local and real server through bastion

first ssh login to bastion, then ssh into remote server, like above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment