Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh and perl

Status
Not open for further replies.

umneydurak

Programmer
Jun 28, 2005
9
US
Hi.
I need to write a script that will connect to another server using SSH and execute some commands. The tricky part is that it has to provide a password, and it can't use any third party libraries. So no Net::SSH::perl. It gets better. Script will be run from multiple servers, but it will be connecting to one server. So creating a key pair for each server is just not an option. Is this possible to do? Please help.

Thank You.
 
I'm not sure that what you ask is possible.
Why the objection to Net::SSH::perl? It's tried and tested and Open Source
--Paul

cigless ...
 
Because I have no control over the servers and what gets installed on them.
 
You could make it a prerequisite for your software

cigless ...
 
If you're able to install your own program on the server, then you have sufficient privileges to install Net::SSH::perl. It's a common misconception that you need root access to install Perl modules. You can install any module if you've even user-level shell access. If you're relying on FTP, it's a little trickier but pure-Perl modules such as Net::SSH::perl are still easily installed.

See here for more on this.
 
If you don't use Net::SSH::perl then why not just use a shell script instead?

You could set up a public/private key system to bypass the tty password and then run the commands one at a time through the script.

I found the Net::SSH::perl to be useless in what I needed so I went for that route, cheers.
 
When I say I have no control over the server I really mean it. I can't install anything on it. Even if I found a way and did it the IT people would skin me alive. Also about the key thing. As I said it's not really an option. The script can be run from at least 20 servers. I don't even know what they all are. Asking a user to do it, isn't really an option either.
Anyway guess it can't be done. thanks.
 
If what you have been asked to provide is a script that can be run from multiple servers, then can I assume that you are allowed to install the script on those servers and that they all have standard perl distributions installed?

If that is the case and, additionally, any non-standard modules that the script requires are pure perl modules, with a little work you can chain all the modules end to end in one script. You might need to enclose them in {} blocks and do a little extra work to preserve the effect of package globals and prevent scope problems but on the whole, splitting modules into separate files is a convenience, not a necessity.

This gives you a much more flexible basis from which to attack the problem.

f

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
You could be lucky and find the modules required are already installed

--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top