Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Net::OpenSSH and Extreme Switch

by rdl (Initiate)
on Nov 23, 2009 at 20:04 UTC ( #808912=perlquestion: print w/ replies, xml ) Need Help??
rdl has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am attempting to use Net::OpenSSH to connect to an Extreme Ethernet switch.

As a test, I am using the following code:

#!/usr/local/bin/perl use strict; use warnings; use Net::OpenSSH; my $ssh = Net::OpenSSH->new( "auto_config\@management", passwd => "myp +asswd", ssh_cmd => '/usr/local/bin/ssh' ); $ssh->error and die "Unable to open ssh connection: " . $ssh->error; print "Sending a command\n"; my $test = $ssh->capture( "show vlan" ); $ssh->error and warn "Operation did not work: " . $ssh->error; print "Output is: \n"; print $test;

When this is run, I get the following output:

Keyboard-interactive authentication Sending a command channel_by_id: 0: bad id: channel free channel_input_status_confirm: 0: unknown Operation did not work: child exited with code 255 at ./ex_ssh.pl line + 12. Output is:

I am able to use OpenSSH from the command line to get to the same box using the same username/passwd from the same server/user. The same script used to run a command on a Sun box works fine.

Thanks, and sorry in advance if I did not post this correctly. I am new here

Comment on Net::OpenSSH and Extreme Switch
Select or Download Code
Re: Net::OpenSSH and Extreme Switch
by salva (Abbot) on Nov 23, 2009 at 21:55 UTC
    Usually these boxes do not allow running single commands via SSH but just a custom/restricted shell.

    What happens when you try to invoke the remote command with SSH as in...?

    $ /usr/local/bin/ssh auto_config@management show vlan

    If it doesn't work, your best option will probably be to use Expect (alone, combined with Net::OpenSSH or via Net::SSH::Expect).

    For simple cases, usually this also works:

    my $out = $ssh->capture({stdin_data => "show vlan\n"}); print "output: $out"

      Salva, thanks for the reply.

      When I try your suggestion from the command line, I get no reply (or error) at all.

      For the second, I modified the script as you suggested

      my $test = $ssh->capture( {stdin_data => "show vlan\n"} );
      and I now get the following:
      Keyboard-interactive authentication Sending a command Pseudo-terminal will not be allocated because stdin is not a terminal. Operation did not work: child exited with code 255 at ./ssh1.pl line 1 +3. Output is: show vlan

      I guess I don't understand why if it works from the command line using OpenSSH, it won't work from the script.

      Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://808912]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2015-07-01 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls