Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: simple iterate and run cmd script

by l2kashe (Deacon)
on Jun 24, 2003 at 15:45 UTC ( [id://268559]=note: print w/replies, xml ) Need Help??


in reply to simple iterate and run cmd script

From personal experiance, here it what I can say. There are a few modules that make life easier in regards to ssh'ing around. Namely Net::SSH, and Net::SSH::Perl. The first is nice, but you *have* to use SSH Key exchange to authenticate against the remote host. This can lead to either security policy or administration nightmares. The second I have gotten to compile on FreeBSD, OpenBSD, and Linux as well as run cleanly without issues. I have had issues with it under Solaris 2.6->2.9. Net::SSH::Perl also has a huge prerequisite list of modules which kind of makes it not so nice for roll out in your enterprise network. Net::SSH::Perl has alot of whizbang functionality that just can't be beat for anything you need to do remotely including inline SCP through the SSH tunnel established.

Now aside from the modules you can use SSH the way you want to. My first guess would be that you are being prompted to provide a password to authenticate against the remote system. But with both system and backticks this should come to STDERR (Im pretty sure its not STDOUT), and read from STDIN. So if you are calling this script from another script you might be missing that prompt. Also the SSH process communicates directy with the tty assigned to you, not the normal handles which makes working with it tricky.

I had to resort to using IPC::Open2 in my attempts to control the spawned process. Ultimately I failed in my attempts to provide a password at run time due to, I think, the fact that I was passing a clear text password to the process, which I think should have been encrypted first, then passed.

So the way around this is again to use SSH Keys, but like I said before make sure that is ok from a security policy standpoint on your network. (Picture someone comprimising the host your code resides on, finding your script, and then making use of the SSH Key exchange mechanism to wander through the hosts in question, all without raising alarms).

One last suggestion would be to try running system("ssh -v $host date"); This will provide a bunch of usefull information and quite possibly could point to what is failing. I.e possible TCP wrappers issues, DNS lookups, etc..

HTH..

MMMMM... Chocolaty Perl Goodness.....

Log In?
Username:
Password:

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

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

    No recent polls found