Skip to content

Instantly share code, notes, and snippets.

@toraritte
Last active July 9, 2017 01:10
Show Gist options
  • Save toraritte/76b9a7664a270b5f1a578a61bd748067 to your computer and use it in GitHub Desktop.
Save toraritte/76b9a7664a270b5f1a578a61bd748067 to your computer and use it in GitHub Desktop.
rsync to remote machine
rsync -avz --delete --progress \
-e "ssh -i ~/.ssh/my_private_key" \ # or just `-e ssh` (see below)
/SOURCE_PATH username@1.2.3.4:/DESTINATION_PATH
# Breaking down:
# -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
#
# -r, --recursive recurse into directories
# -l, --links copy symlinks as symlinks
# -p, --perms preserve permissions
# -t, --times preserve modification times
# -g, --group preserve group
# -o, --owner preserve owner (super-user only)
# -D same as --devices --specials
# --devices preserve device files (super-user only)
# --specials preserve special files
# --delete delete extraneous files from dest dirs
# --progress show progress during transfer
# -e, --rsh=COMMAND specify the remote shell to use
#
# If you are using public-key authentication and your
# private key's name differs from the default then you
# can provide it with `-i`.
#
# From `man ssh`:
# -i identity_file
# Selects a file from which the identity (private key) for public
# key authentication is read. The default is ~/.ssh/identity for
# protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa,
# ~/.ssh/id_ed25519 and ~/.ssh/id_rsa for protocol version 2.
# Identity files may also be specified on a per-host basis in the
# configuration file. It is possible to have multiple -i options
# (and multiple identities specified in configuration files). If
# no certificates have been explicitly specified by the
# CertificateFile directive, ssh will also try to load certificate
# information from the filename obtained by appending -cert.pub to
# identity filenames.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment