Skip to content

Instantly share code, notes, and snippets.

@ppdouble
Last active July 21, 2023 10:11
Show Gist options
  • Save ppdouble/98bb6b06e7f65b8508d210ee5ec86c82 to your computer and use it in GitHub Desktop.
Save ppdouble/98bb6b06e7f65b8508d210ee5ec86c82 to your computer and use it in GitHub Desktop.
Copy files from remote host to local machine with specific port using rsync. Alternative of scp. To copy a large number of files from remote.
# https://stackoverflow.com/questions/9090817/copying-files-using-rsync-from-remote-server-to-local-machine
# https://explainshell.com/explain?cmd=rsync+-havzP+-e+%22ssh+-p+%24portNumber%22+user%40remote.host%3A%2Fpath%2Fto%2Fcopy+%2Flocal%2Fpath
# copy files from remote host with specific ssh port
rsync -havzP -e "ssh -p portNumber" user@remote.host:/path/to/copy /local/path
# copy abc into local def
rsync -avzP user@remote-host:/source/folder/abc /destinate/folder/def/
# copy the files in abc into local abc
rsync -avzP user@remote-host:/source/folder/abc/ /destinate/folder/abc/