On 8/25/06, Alexander Hall <[EMAIL PROTECTED]> wrote:
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.

Understood but how come the exact setup works from my system corn to
rice ( but not grits to rice)?  corn is 3.8, grits is 3.9, and rice is
4.0.  Default ssh setup on all three except for:

PermitRootLogin no

[EMAIL PROTECTED] sudo backup_inc.sh

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

   #1) Respect the privacy of others.
   #2) Think before you type.
   #3) With great power comes great responsibility.

Password:
 DUMP: Date of this level 1 dump: Fri Aug 25 10:33:33 2006
 DUMP: Date of last level 0 dump: Thu Aug 24 00:03:12 2006
 DUMP: Dumping /dev/rwd0a (/) to standard output
 DUMP: mapping (Pass I) [regular files]
 DUMP: mapping (Pass II) [directories]
 DUMP: estimated 144 tape blocks.
 DUMP: Volume 1 started at: Fri Aug 25 10:33:36 2006
 DUMP: dumping (Pass III) [directories]
 DUMP: dumping (Pass IV) [regular files]
 DUMP: 147 tape blocks
 DUMP: Volume 1 completed at: Fri Aug 25 10:33:36 2006
 DUMP: Date of this level 1 dump: Fri Aug 25 10:33:33 2006
 DUMP: Date this dump completed:  Fri Aug 25 10:33:36 2006

[EMAIL PROTECTED] cat backup_inc.sh
#!/bin/sh
/sbin/dump -1auf - /dev/rwd0a | gzip | \
  ssh [EMAIL PROTECTED] "cat > /laptops/corn/$(date "+%Y%m%d")_root1.dump.gz"
/sbin/dump -1auf - /dev/rwd0d | gzip | \
  ssh [EMAIL PROTECTED] "cat > /laptops/corn/$(date "+%Y%m%d")_var1.dump.gz"
/sbin/dump -1auf - /dev/rwd0f | \
  ssh [EMAIL PROTECTED] "cat > /laptops/corn/$(date "+%Y%m%d")_home1.dump"
/sbin/dump -1auf - /dev/rwd0e | gzip | \
  ssh [EMAIL PROTECTED] "cat > /laptops/corn/$(date "+%Y%m%d")_usr1.dump.gz"


Possible solutions:
1) Add yourself to group operator, which removes the need for ``sudo''.

Yep, that works fine.

2) Use sudo only for the dump command within the script.
3) Instruct ssh to use the designated key using ``-i identity_file''

Thanks for the tips.

Greg

Reply via email to