Re: ssh and sudo not working together....

2005-10-18 Thread Chris Devers
On Mon, 17 Oct 2005, O'Brien, Bill wrote:

> I have this so far but it is not allowing sudo, just wondering if it 
> is NET::SSH or that RSA type of SSH we are running?  I have tried to 
> pass numerous commands but that doesn't seem to work, how can I run 
> numerous commands via the single SSH connection?

Stepping away from Perl for a moment, if you're trying to have ssh run 
an interactive command, such as sudo, then you have to allocate a tty 
for that command to interact within. With the ssh command, you have:

  $ man ssh | grep -i '\-[a-z] .*alloc'
-T   Disable pseudo-tty allocation.
-t   Force pseudo-tty allocation. This can be used to execute arbi-
  $

Therefore, you can do things like:

  $ ssh -t [EMAIL PROTECTED] "sudo ls -al"

This will connect to $host and issue the command; sudo will then come 
back over the ssh connection and ask you to authenticate; once that is 
done, sudo will then proceed as normal. 

So, to get back to your question, I think what you need to do is figure 
out a way to pass the -t argument to ssh via Net::SSH. Skimming over the 
perldoc at , it looks like 
you might be able to use the ssh_cmd() method to set this up. Look up 
the section that mentions OPTIONS_HASHREF for hints, and good luck!



-- 
Chris Devers

÷0~‹œg±êˆ
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


ssh and sudo not working together....

2005-10-17 Thread O'Brien, Bill
Greetings,

I have a perl script that is using telnet that I need to switch to SSH
and I'm having some issues. First is I need to use sudo to run the
command on the server I'm connecting to and second I need to run more
then one command, I'll then save all this output.

I have this so far but it is not allowing sudo, just wondering if it is
NET::SSH or that RSA type of SSH we are running?  I have tried to pass
numerous commands but that doesn't seem to work, how can I run numerous
commands via the single SSH connection?

#!/usr/bin/perl
use Net::SSH qw(sshopen2);
use strict;

my $user = "ops";
my $host = "prserver07a";
my $cmd = "ls -al";
my $cmd2 = "sudo opcagt";

sshopen2 ("[EMAIL PROTECTED]", *READER, *WRITER, "$cmd2")  || die "ssh: $!";

while () {
chomp();
print "$_\n";
}

close (READER);
close (WRITER);



Thanks

Bill