Originally Posted by
KB1JWQ
You can pass the key location via ssh -i; man ssh for more info on this.
It still doesn't work. Here is what my script looks like now:
Code:
#! /bin/bash
ssh -i ~/.ssh/id_rsa server "/srv/app/make_db_dump";
echo "after ssh";
scp -i ~/.ssh/id_rsa server:/srv/app/dump .;
echo "after scp";
exit
and it works fine when I run the script directly, but the cron job:
Code:
*/2 * * * * /path/to/myscript > /home/chris/err.log 2>&1
outputs this:
Code:
~$ cat err.log
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
after ssh
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
after scp
OK I think I just found the problem. I added "echo $USER" to the script, which outputs "chris" when I run from the command line, but when ran from cron, returns a blank line. This is very odd. I'm adding this crontab by typing "crontab -e" as the user "chris"
Bookmarks