LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 06-25-2010, 10:43 AM   #1
Sum1
Member
 
Registered: Jul 2007
Distribution: Slackware and Gentoo
Posts: 227

Rep: Reputation: 21
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.

Last edited by Sum1; 06-25-2010 at 10:44 AM.
 
Old 06-25-2010, 11:00 AM   #2
mpapet
Member
 
Registered: Nov 2003
Location: Los Angeles
Distribution: debian
Posts: 452

Rep: Reputation: 46
This should do it: http://www.csua.berkeley.edu/~ranga/...sh_nopass.html
 
Old 06-25-2010, 11:30 AM   #3
Sum1
Member
 
Registered: Jul 2007
Distribution: Slackware and Gentoo
Posts: 227

Original Poster
Rep: Reputation: 21
Thanks Mpapet, I'll give it a try over lunch. :-)
 
Old 06-25-2010, 12:30 PM   #4
Sum1
Member
 
Registered: Jul 2007
Distribution: Slackware and Gentoo
Posts: 227

Original Poster
Rep: Reputation: 21
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.
 
Old 06-25-2010, 12:40 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora, Lubuntu, FreeBSD
Posts: 3,930
Blog Entries: 5

Rep: Reputation: Disabled
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.

Last edited by anomie; 06-25-2010 at 12:42 PM.
 
Old 06-25-2010, 01:38 PM   #6
Sum1
Member
 
Registered: Jul 2007
Distribution: Slackware and Gentoo
Posts: 227

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by anomie View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SSH public key authentication Jeroen1000 Linux - Security 12 09-07-2009 04:14 AM
Rsync copies my SSH key over when I don't want it to Raze Programming 3 07-27-2009 12:40 AM
Public key authentication with ssh elnacho12 Linux - Networking 3 12-18-2007 08:38 AM
Public Key Authentication with SSH edafe Ubuntu 1 08-26-2006 11:06 AM
Can't use public key authentication with SSH Noob69 Linux - General 5 01-06-2006 06:27 AM


All times are GMT -5. The time now is 09:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration