Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  36] [ 0]  / answers: 1 / hits: 68808  / 3 Years ago, sat, july 3, 2021, 11:47:32

I want to set up an RSync job that would connect through SSH.



I have my computer ( backup@myhost ) and the remote host ( test@remhost ) and I need to backup the folder ~/something with all it's contents. The ssh user test only has READ access to all files and folders in the ~/ folder. I want to use rsync to copy the test@remhost:~/something folder to the backup@myhost:~/bak folder.



For this purpose I use the following command via BASH on Ubuntu 11.10 (Oneiric):



rsync -avz -e ssh test@remhost:~/something/ ~/bak/


After hitting enter I get this:



test@remhost's password:


I type the password and the rsync works.



I want to make the above command to automatically input the password and pass it as a parameter or to input it automatically and start the job.



I tried executing rsync -avz -e ssh test:password@remhost:~/something/ ~/bak/ but it still asks for the password and it's annoying.



I don't want to hear about any kind of keys (RSA,DSA or any other). I just want a simple command that would log me in and do the job.



EDIT: A possible scenario could be, if public key authentication is disabled and you can't change this. E.g. if you use OpenSSH, you'd need root privileges on the server in order to edit the file sshd_config and to add PubkeyAuthentication yes.



EDIT: This is what finally worked for me:



sshpass -p 'sshpassword' rsync --progress -avz -e ssh test@remhost:~/something/ ~/bak/


Please note that this method is not considered secure as it sends the password in plain text and it's vulnerable to man-in-the-middle attacks. It is advised to use the key athentication for a stronger security.


More From » bash

 Answers
4

maybe try sshpass.



seems simple enough to use... it's available through apt as well.



I was looking for something like this before I copied my keys around, but since I've got my key everywhere I need already anyway, I haven't taken the time to try this.



Do note the disclaimer on that tutorial there regarding the visibility of your password though.






For everyone who needs to do this:



sshpass -p 'sshpassword' rsync --progress -avz -e ssh test@remhost:~/something/ ~/bak/

[#41116] Monday, July 5, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
housecoarmer

Total Points: 434
Total Questions: 116
Total Answers: 120

Location: Albania
Member since Sun, Nov 22, 2020
4 Years ago
;