rsync over SSH
Перевод: Запуск RSync через SSH
rsync over SSH
I’ve migrated a few rsync pages yesterday and realised there’s been something I’d wanted to document for some time: using rsync over ssh.
rsync initially started as a tool for synchronising local folders, then expanded to also working with external drives, then progressed to working with networking folders and eventually started working with remote servers using its own native rsync protocol.
Why You Need rsync Over SSH
Modern Linux systems support running rsync over SSH, which gives you best of two worlds: you get remote access AND you make sure your transfer is secure.
Additionally, using SSH transport has two more benefits over the native rsync protocol:
- You don’t need rsyncd daemon listening on the remote server
- You don’t need to open additional ports (873/tcp for rsyncd) since SSH port 22 is likely to be available out of the box.
How To use rsync with SSH
In most cases, there’s nothing additional needed. But just to be on the safe side, use -e option to specify your SSH intention:
In this command line above:
newscripts
is the name in my current location
becky
is the hostname of my Raspberry Pi server
/home/greys/scripts
is the destination directory name - this will be created on becky
The behaviour of rsync command above is that I’ll end up with the exact copy of my local newscripts directory on Macbook with the remote /home/greys/scripts directory.
Let’s run it:
The Key Benefit of Using RSync
The key benefit is synchronising two specified locations. Simply put, it means if I change a file or two in my local newscripts directory, I won’t have to copy the whole thing over to the remote server - I can use the same rsync command to sync it again and rsync itself will figure out which files must be transferred, saving me time and bandwidth.
So newscripts directory has the following in it:
Let’s change two of the files:
And re-run rsync
. See how its output differs from the first run? It only transfers the 2 files that I changed:
That’s it for now. Have fun!
See Also
rsync over SSH
I’ve migrated a few rsync pages yesterday and realised there’s been something I’d wanted to document for some time: using rsync over ssh.
rsync initially started as a tool for synchronising local folders, then expanded to also working with external drives, then progressed to working with networking folders and eventually started working with remote servers using its own native rsync protocol.
Why You Need rsync Over SSH
Modern Linux systems support running rsync over SSH, which gives you best of two worlds: you get remote access AND you make sure your transfer is secure.
Additionally, using SSH transport has two more benefits over the native rsync protocol:
- You don’t need rsyncd daemon listening on the remote server
- You don’t need to open additional ports (873/tcp for rsyncd) since SSH port 22 is likely to be available out of the box.
How To use rsync with SSH
In most cases, there’s nothing additional needed. But just to be on the safe side, use -e option to specify your SSH intention:
In this command line above:
newscripts
is the name in my current locationbecky
is the hostname of my Raspberry Pi server/home/greys/scripts
is the destination directory name - this will be created on becky
The behaviour of rsync command above is that I’ll end up with the exact copy of my local newscripts directory on Macbook with the remote /home/greys/scripts directory.
Let’s run it:
The Key Benefit of Using RSync
The key benefit is synchronising two specified locations. Simply put, it means if I change a file or two in my local newscripts directory, I won’t have to copy the whole thing over to the remote server - I can use the same rsync command to sync it again and rsync itself will figure out which files must be transferred, saving me time and bandwidth.
So newscripts directory has the following in it:
Let’s change two of the files:
And re-run rsync
. See how its output differs from the first run? It only transfers the 2 files that I changed:
That’s it for now. Have fun!