Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] user cron-job with ssh-agent/keychain, pubkey error
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Seron
Apprentice
Apprentice


Joined: 31 Dec 2002
Posts: 293
Location: Malmö, Sweden

PostPosted: Fri Apr 26, 2013 3:05 pm    Post subject: [solved] user cron-job with ssh-agent/keychain, pubkey error Reply with quote

I've set up a user cronjob for running a script to rsync using ssh. When I run the script on the command line I don't get prompted for the key passphrase, but when executed by cron I get the following email:
Code:
Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [Receiver=3.0.9]

What could be the reason for this?

vixie-cron-4.1-r12
openssh-5.9_p1-r4
keychain-2.7.1-r1

script:
Code:
#!/bin/bash
rsync --archive --update --verbose --compress --progress --rsh="ssh" --exclude='lost+found' source_srv:dir1/ /destination/dir

ssh connection parameters are set in ~/.ssh/config.
_________________
man cannot be brave without being afraid


Last edited by Seron on Fri Apr 26, 2013 3:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
Seron
Apprentice
Apprentice


Joined: 31 Dec 2002
Posts: 293
Location: Malmö, Sweden

PostPosted: Fri Apr 26, 2013 3:27 pm    Post subject: Reply with quote

I got it working by adding the following to the beginning of the script:
Code:
eval "$(keychain --noask --eval id_dsa)" || exit 1
as described in the Keychain Wiki.
_________________
man cannot be brave without being afraid
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum