Greg Thomas wrote:
I've got a little backup script piping dump to ssh to my backup server
rice, and I've got my keys setup:

[EMAIL PROTECTED]:/home/ethant# sudo /sbin/dump -0auf - /dev/rwd0a | gzip | \
ssh [EMAIL PROTECTED] "cat > /grits/$(date "+%Y%m%d")_root.dump.gz"

Here you are running ssh as yourself, thereby using your own keys.

 DUMP: Date of this level 0 dump: Fri Aug 25 00:21:08 2006
...
================================================

But when I run this simple script (an almost identical copy of which
is working fine on another laptop with 3.8 installed, the only
difference is the path to the dump) I get prompted for my password:

[EMAIL PROTECTED]:/home/ethant# cat test.sh
#!/bin/sh
/sbin/dump -0auf - /dev/rwd0a | gzip | \
  ssh [EMAIL PROTECTED] "cat > /grits/$(date "+%Y%m%d")_root.dump.gz"

[EMAIL PROTECTED]:/home/ethant# sudo test.sh
 DUMP: Date of this level 0 dump: Fri Aug 25 00:23:42 2006
...
[EMAIL PROTECTED]'s password:

What am I doing wrong?

Here you are running the entire script as root (using sudo), and therefore ssh is run as root, which does not have your keys.

Possible solutions:
1) Add yourself to group operator, which removes the need for ``sudo''.
2) Use sudo only for the dump command within the script.
3) Instruct ssh to use the designated key using ``-i identity_file''

/Alexander

Reply via email to