how to copy my *!&^%# log files
John Abreau
jabr at abreau.net
Wed Jun 4 16:58:49 EDT 2003
On Tue, 2003-06-03 at 14:09, Greg Rundlett wrote:
> I can now issue commands like
>
> /usr/bin/scp joe at example.com:/usr/home/joe/www_logs/* /var/log/httpd
>
> without supplying a password. I can put it into a shell script and
> execute that script without a password.
>
> WHY doesn't it work from cron as advertised? I simply used crontab -e
> to put the right command in my crontab, but I'm getting authentication
> errors:
Looks to me like your cron job isn't finding your ssh-agent instance.
A process run from cron isn't going to pick up ssh-agent's environment
variables from your user process.
You didn't specify the details of what you put into your crontab, so
I can't tell exactly what went wrong. The way I usually do this is to
dump ssh-agent's environment variables into a file, then use a shell
script in cron that sources the file before running ssh.
So I'd start up ssh-agent like this:
ssh-agent | head -2 > /usr/home/joe/ssh-agent-id
source /usr/home/joe/ssh-agent-id
ssh-add
Then the cron job would run a script like this:
#! /bin/bash
source /usr/home/joe/ssh-agent-id
/usr/bin/scp joe at example.com:/usr/home/joe/www_logs/* /var/log/httpd
I use the "head -2" because ssh-agent puts an "echo" command after the
environment variables it provides, and I don't want that appearing
in the sourced file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20030604/340a9b59/attachment.bin
More information about the gnhlug-discuss
mailing list