Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Using SSH and SCP in a perl script with taint flag

by salva (Canon)
on May 29, 2015 at 11:01 UTC ( [id://1128250]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using SSH and SCP in a perl script with taint flag
in thread Using SSH and SCP in a perl script with taint flag

The problem is that the OpenSSH client ssh is not in the scrawny path you are using. Try adding /usr/bin too:
$ENV{PATH} = "/bin:/usr/bin";

Replies are listed 'Best First'.
Re^4: Using SSH and SCP in a perl script with taint flag
by stefl (Acolyte) on May 29, 2015 at 14:20 UTC

    Thanks very much salva, your advice was brilliant. Got it working now, you've saved me days of frustration! For anyone else in my situation who is new to this stuff, I fixed this by adding the ctl_dir option:  my $ssh = Net::OpenSSH->new($host, user=>$user, ctl_dir=>$ctldir);. I created the $ctldir (called .libnet-openssh-perl) within my /var/www directory and ensured the owner was www-data.
    I hope this can help someone else too! Thanks again salva, legend!

Re^4: Using SSH and SCP in a perl script with taint flag
by stefl (Acolyte) on May 29, 2015 at 13:31 UTC

    Genius! Thanks very much! Is there anything special I need to do to get this to work when running the script as www-data? On the command line (to emulate running the webform) I run it as follows:  sudo -u www-data perl -T test but get an error message: Can't ssh to host: unable to create ctl_dir /var/www/.libnet-openssh-perl
    This might be more of a general Linux question, in which case I apologise. I am able to ssh as the www-data outwith the perl script though, so I don't know what is wrong.
    Thanks very much for your advice, you seem to know a lot about using this module and I'm very, very new to this sort of thing.

      The module is trying to create the directory /var/www/.libnet-openssh-perl but it can't. It needs it to place a UNIX socket there for communication with the OpenSSH client.

      The module documentation has a TROUBLESHOOTING section that discusses most of the issues you can encounter in detail. You should read it. But in any case, fell free to ask here again if that doesn't solve your problems.

      you seem to know a lot about using this module

      Hey, I should! I wrote it!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128250]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found