“rsync” is a file transfer program you can use to update files to (and from) a remote computer in an efficient way. It’s usually pre-installed in most Linux distros.

rsync [<options>] <source> <destination>

The source or the destination can be remote hosts, like: user@host:/path/.

rsync ./folder/ ricardo@
  • You can specify an SSH private key:
    rsync -a -v -e "ssh -i <private-key-file>" <local-folder> <user>@<server-ip>:<remote-folder>
    • -a means “archive mode” and is a shortcut for recursive into directories, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve owner (using “sudo”), preserve device files (using “sudo”) and preserve special files.
    • -e allows to specify the remote shell to use, in this case it allows to specify the SSH parameters (private key and port, for example). If you connect to server with a password, you don’t need to add this parameter.
    • -v show the process.
  • You can exclude files with --exclude PATTERN:
    rsync -a <local-folder> <user>@<ip>:<remote-folder> --exclude "*.txt"

If you omit the destination, it will show a file list of the specified directory.

$ rsync ricardo@
ricardo@'s password: 
drwxr-xr-x          4,096 2021/11/15 16:30:14 .
-rw-------            141 2021/11/16 18:51:44 .bash_history
-rw-r--r--            220 2021/11/12 13:38:53 .bash_logout
-rw-r--r--          3,526 2021/11/12 13:38:53 .bashrc
-rw-r--r--            807 2021/11/12 13:38:53 .profile
-rw-r--r--     10,485,760 2021/11/15 13:47:15 testfile
drwx------          4,096 2021/11/15 16:30:14 .ssh

If you have any suggestion, feel free to contact me via social media or email.