kazeeks has asked for the wisdom of the Perl Monks concerning the following question:
1. $ssh_out = `ssh -2 $user\@$host $ssh_cmd`;
This gets complicated when running multiple commands (I have a few loops that generate a directory hierarchy). I also don't know how to send data to the stdin when prompted, so if my $ssh_cmd starts with a 'sudo', I have to type the password manually.
2. system "ssh -2","$user",'@',"$host","$ssh_cmd";
This gives me similar problems as above, as well as issues with my chgrp command, which must include a backslash as part of the group name.
3. using Net::SSH
I don't immediately see how to pass options to ssh itself, like the -2 or a -v. It also seems difficult, or at least expensive, to work this thru a loop.
4. using Net::SSH::Perl
Because this requires dozens of dependencies, I'm having great difficulty compiling and installing this under OS X.
What's the best way to open an SSH connection with a remote host and run a bunch of commands, some as the super-user, without asking for a password. I've already exchanged SSH keys so I can log in from the terminal without supplying a password (yes, it's insecure, i know).
Thanks
Disclaimer: I'm a self-taught sysadmin, and an even newer self-taught perl enthusiast; this is my first script using cpan modules. No formal training in CompSci or programming. Electronics is my thing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Installing Net::SSH::Perl on OS X, or how to run commands remotely
by idsfa (Vicar) on Sep 28, 2005 at 14:49 UTC | |
by pingme8705 (Acolyte) on Sep 29, 2005 at 06:06 UTC | |
|
Re: Installing Net::SSH::Perl on OS X, or how to run commands remotely
by kwaping (Priest) on Sep 28, 2005 at 15:10 UTC |