rsync – perform upload with password

rsync – perform upload with password

Many of you will be looking for a way to specify a password for upload/download in rsync.

This is possible via a small detour and with the tool sshpass.

To do this, sshpass must first be installed

apt-get install sshpass

finally, you still need to disable the HostKeys check for your target (or add the HostKey)

vi /etc/ssh/ssh_config

Here is a new entry with the values

Host yourstorage.com.
StrictHostKeyChecking no

to create, saved with

:wq

After that, it is possible to use rsync as follows:

sshpass -p "verySecurepassword" rsync --remove-source-files --progress -e 'ssh -p23' --recursive /home/source-directory benutzername@deinspeicherplatz.de:/

The above command will automatically delete the source files (–remove-source-files) after the upload and show you the status of the upload (–progress). It uses port 23 (-p23) and uploads (–recursive) everything in the source directory (/home/source-directory) to the destination (benutzername@deinspeicherplatz.de:/zielverzeichnis).

If you want to prevent the upload from aborting if you lose connection yourself, it is always recommended to use screen, such as here:

screen -mdS meinupload sshpass -p "verySecurepassword" rsync --remove-source-files --progress -e 'ssh -p23' --recursive /home/source-directory benutzername@deinspeicherplatz.de:/

Leave a Reply

Your email address will not be published. Required fields are marked *

*

code