[Omaha.pm] Net::SSH::Perl and sudo or su

Jay Hannah jay at jays.net
Thu Dec 6 14:36:29 PST 2007


Tony Simons wrote:
> Ok, but it's really long... But... this is what I have.  And it's a
> little rough but it works.
> if [ `sudo test; echo $?` -gt 1 ]; then
>     echo "This script uses SinFP which requires Root privileges please
>   

So you have to be root to run your bash script?

>     case `sudo sinfp.pl -a -i${SNFILE[${HOS}]} -p 22 | grep IPv4 | awk
> '{print $4}' | head -n1` in
>   

What does sudo do if you're already root?

>          echo "No Unix Fingerprint Found...doing one more check!"
>         if [ "`sudo sinfp.pl -i${SNFILE[${HOS}]} -p 22 | grep IPv4 | awk
> '{print $2}' | head -n1`" == "unknown" ]; then
>   

What is that doing? Is it doing it locally?

>     $SSHCMD ${SNFILE[${HOS}]} "echo -e $STR > /tmp/${SNFILE[${HOS}]}.sn
> ;$SUDO mv /tmp/${SNFILE[${HOS}]}.sn /etc/serialnumber; $SUDO chmod 660
> /etc/serialnumber"
>   

So this is our goal, right? To create /etc/serialnumber on the remote host?

Why does this work under bash? Do all your remote hosts have 
/root/.ssh/authorized_keys files set up to trust root coming from your 
local machine?

... Maybe we'll get to a Perl question eventually ...  -grin-

j




More information about the Omaha-pm mailing list