LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   rsync over ssh: authentication by cryptographic key (https://www.linuxquestions.org/questions/linux-networking-3/rsync-over-ssh-authentication-by-cryptographic-key-816362/)

Sum1 06-25-2010 10:43 AM

rsync over ssh: authentication by cryptographic key
 
I have 2 boxes, both using Slackware64 ver. 13.
Box1 - ssh server and rsync server daemon are functional.
Box2 - client box that connects to Box1 by ssh as well as rsync by way of ssh.

I followed the instructions in Chapter 2 of the O'Reilly book "The Secure Shell, The Definitive Guide" to setup ssh authentication by pub/private keys.

The configuration works, but only once, and upon re-logging into Box2, I find I have to go through the following setup to make it work again -

$ssh-agent $SHELL
$ssh-add /home/mike/.ssh/id_rsa
then prompted to provide passphrase.

Then rsync over ssh will work - example:

rsync -e "ssh -p 45000" -avzi mike@10.10.10.100:/zzz /mnt/current

I want to get it configured so that it works every time with no user input, in order to configure automatic cronjobs using rsync commands like the one above.

Thanks for your help.

mpapet 06-25-2010 11:00 AM

This should do it: http://www.csua.berkeley.edu/~ranga/...sh_nopass.html

Sum1 06-25-2010 11:30 AM

Thanks Mpapet, I'll give it a try over lunch. :-)

Sum1 06-25-2010 12:30 PM

I completed the instructions according to the linked web-page and it works perfectly when I am logged in as the user; however, it does not work when logged in as root. When I execute the rsync-via-ssh bash script, I get prompted for a password.

I think I've found a new issue that requires a new question --

Is it possible to run a particular cronjob as a user?
I believe when I put the rsync bash script in as a cronjob, it is executed by the root account, and will fail to complete just like it did when I try manually while logged in as root.

Is this the correct way to state a user-specified cronjob? -

15 * * * * mike /home/mike/my_rsync_bash_script >> /dev/null 2>&1

Thanks for your time and help.
Very much appreciated.

anomie 06-25-2010 12:40 PM

Quote:

Originally Posted by Sum1
I completed the instructions according to the linked web-page and it works perfectly when I am logged in as the user; however, it does not work when logged in as root. When I execute the rsync-via-ssh bash script, I get prompted for a password.

If you generate a keypair for one user, the private key is generally available to that user and no one else. For this authentication scheme to behave otherwise would be a major security problem.

Just run through the same key generation steps (and the steps that follow) for root, and you should be in business.

Sum1 06-25-2010 01:38 PM

Quote:

Originally Posted by anomie (Post 4014966)
Just run through the same key generation steps (and the steps that follow) for root, and you should be in business.

Right you are; right you are, indeed. :-)

Thanks to you too, Anomie.


All times are GMT -5. The time now is 02:25 AM.