Skip to content

Rsync over SSH


Rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files.It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. The rsync algorithm is a type of delta encoding, and is used for minimizing network usage. Zlib may be used for additional data compression, and SSH or stunnel can be used for data security.

Rsync is typically used for synchronizing files and directories between two different systems.

About SSH

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line login and remote command execution, but any network service can be secured with SSH.

SSH provides a secure channel over an unsecured network in a client–server architecture, connecting an SSH client application with an SSH server. The protocol specification distinguishes between two major versions, referred to as SSH-1 and SSH-2. The standard TCP port for SSH is 22. SSH is generally used to access Unix-like operating systems, but it can also be used on Windows. Windows 10 uses OpenSSH as its default SSH client.

Example of uses

Synchro local to remote

To synchronyze my local files into my remote server.

rsync -azvhPe ssh /your/source/folder/file login@IP_SERVER_SSH:/your/destination/folder/file

Synchro remote to local

To synchronyze my remote files into my local machine.

rsync -avzhPe ssh login@IP_SERVER_SSH:/your/source/folder/file /your/destination/folder/file

Local to remote with different port

In this example we go on the case where the remote server have a different port as the default.

In our example the default ssh port is tcp/65022.

rsync -avzhP -e 'ssh -p 65022' --stats /your/source/folder/file login@IP_SERVER:/your/destination/folder/file

Arguments :

  • a : Archive mod.
  • v : Verbose mod.
  • z : Compress the transfert.
  • h : Human readable output.
  • P : Progress mode. (Display the progression)
  • e : Execute an alternative remote shell of our choice like ssh or rsh (usefull when we use an alternate ssh port instead of tcp/22)

They exist several other case usage with rsync over ssh of course. If you want to go far man rsync can be very helpfull.