Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpclark/f9c458bb417e134d37ab6e68d8be147f to your computer and use it in GitHub Desktop.
Save danielpclark/f9c458bb417e134d37ab6e68d8be147f to your computer and use it in GitHub Desktop.

All of the following commands are to be run on the remote machine where the files to copy are

We need a key to connect with SSH

ssh-keygen -t rsa -b 4096

Put that pub key in the destination machine's ~/.ssh/authorized_keys

(asuming destination SSH is up and configured for accepting keys)

cat ~/.ssh/id_rsa.pub

Copy file to a safe place to work with as RSync's --delete flag is destructive if you mix the source and destinations up

cp -R source_directory ~/
cd ~/

Transfer the files

rsync -ravz -e 'ssh -p PORT_NUMBER' --progress --delete source_directory dest_user@dest_url:/dest/path/

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