How To Quickly Copy Files Over Network In Linux Using Rsync Over SSH

When trying to copy lots of files remotely from one server to the other, rsync over ssh can be of a great help in most Linux distros including Linux Mint and Ubuntu. [ For a quick primer on how to use ssh from Linux Mint/Ubuntu command line, check this post ].

Here is how to use it considering the below example :

1. Folder named “images” resides locally at “/home/avp/images”.

2. Files in this folder need to be copied to a remote server whose IP address is 192.168.10.6 over ssh with credentials of a user named “avp”. The destination folder where they need to be copied is “content”. (For copying to a remote server on internet, either IP address or the whole name of the server can be used.)

To do this, open Terminal on the local Linux machine and give the following command :

rsync -avz  -e ssh /home/avp/images/ avp@192.168.10.6:/content/

Enter the password when prompted and let the copying begin. Once over, all the files from local folder will be copied to the remote folder.

If the ssh access to the remote server is through any other port (say 2222) , add the -p switch after ssh so that it looks like this :

rsync -avz -e  "ssh -p 2222" /home/avp/images/ avp@192.168.10.6:/content/

This is by the way a quick method to transfer all the folder contents from one server to the other when moving between web hosts. Simply ssh to the current host and copy all files to the other web host. 🙂

Cheers.