0

I have created 2 servers, new to ssh sshpass s1 ip 192.168.1.245 s2 ip 192.168.1.76 wanted to copy files in s1>>/opt/files to s2>>/home/s2/backup

objective: put 1 sentence in cron to do auto rsync

i have these method

1) using ssh rsa key method, genkey and copy over the key it works for direct access. doesnt meet my need for rsync files perhaps i did wrong or missing steps or issue wrong commands

2) tried SSHPASS can store pass but still doesnt work

3) SSH + SSHPASS getting all kinds of error

The above 3 methods are google using SSH without password and SSHPASS without password

Any expert could provide me with one line command or suggestion?

0

You can leave the password blank when generating the private keys, if you do so, it will not ask for a password when establishing the connection later.

rsync should work if you can establish a connection for "direct access" without a password, as long as you are using the same user (crontab -e). If you are running this from a root crontab (/etc/crontab or /etc/cron.*) then you also need to make rsync/ssh use the correct identity, you can do so with:

rsync -av -e "ssh -i /home/username/.ssh/id_rsa" /source/folder/ username@server:/destination/folder/
  • rsync -av -e "ssh -i /home/username/.ssh/id_rsa" /source/folder/ username@server:/destination/folder/ Will attempt shortly Thanks for advice – YCLEE Jun 14 '16 at 3:29
  • I love you babe, you had solved my problem in a nite that i had been googling for answers with SSH SSHPASS even tried UNISON for the pass 2weeks. Thank you very much – YCLEE Jun 14 '16 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.