I know I've used this answer before on this list, and I'm sure it's annoying, but if your solution involves passphraseless ssh keys, you're doing it wrong.<div><br></div><div>That being said, since cron is a daemon, it is not attached to a controlling terminal. That means that a script that expects to be able to read input from the user is going to fail. You can probably force it to bypass this code with BatchMode.</div>
<div><br></div><div> ssh -o BatchMode=yes ...</div><div><br></div><div>For good measure, you could even set TERM if it's not being set.</div><div><br></div><div> env TERM=dumb ssh -o BatchMode=yes ...</div><div>
<br><div class="gmail_quote">On Wed, Mar 16, 2011 at 9:43 AM, Bruce Wolk <span dir="ltr"><<a href="mailto:bawolk@ucdavis.edu">bawolk@ucdavis.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I need to copy a file from my server to a workstation on a regular<br>
basis. I have set up passwordless ssh access to the server from my<br>
workstation. When I execute the following on the workstation, the<br>
command succeeds and the file is copied:<br>
<br>
scp -P 33303 bruce@myserver.com:backup/db.sql.gz<br>
/home/bruce/backup/db.sql.gz<br>
<br>
But when I put the same command into a cron file on the workstation, the<br>
command fails. The relevant output from the scp command is:<br>
<br>
debug1: Found key in /home/bruce/.ssh/known_hosts:5<br>
debug1: ssh_rsa_verify: signature correct<br>
debug1: SSH2_MSG_NEWKEYS sent<br>
debug1: expecting SSH2_MSG_NEWKEYS<br>
debug1: SSH2_MSG_NEWKEYS received<br>
debug1: Roaming not allowed by server<br>
debug1: SSH2_MSG_SERVICE_REQUEST sent<br>
debug1: SSH2_MSG_SERVICE_ACCEPT received<br>
debug1: Authentications that can continue: publickey<br>
debug1: Next authentication method: publickey<br>
debug1: Offering public key: /home/bruce/.ssh/id_rsa.pub<br>
debug1: Server accepts key: pkalg ssh-rsa blen 279<br>
debug1: PEM_read_PrivateKey failed<br>
debug1: read PEM private key done: type <unknown><br>
debug1: read_passphrase: can't open /dev/tty: No such device or address<br>
debug1: No more authentication methods to try.<br>
Permission denied (publickey).<br>
<br>
I edited the cron file using crontab -e and have verified that it is<br>
excecuting properly as user bruce.<br>
<br>
I googled around but found nothing that helps. Why would the<br>
authentication work with direct execution, but fail with cron execution?<br>
Does anyone have any ideas?<br>
<br>
Bruce<br>
_______________________________________________<br>
vox-tech mailing list<br>
<a href="mailto:vox-tech@lists.lugod.org">vox-tech@lists.lugod.org</a><br>
<a href="http://lists.lugod.org/mailman/listinfo/vox-tech" target="_blank">http://lists.lugod.org/mailman/listinfo/vox-tech</a><br>
</blockquote></div><br></div>