http://qs321.pair.com?node_id=515334

shonorio has asked for the wisdom of the Perl Monks concerning the following question:

Hi Mongers,

I'm writting scripts that will get information on firewall Linux Debian from a Windows server, and to get my job done, I think to use Net::SSH::Perl (version 1.29).

But i'm getting two different problem with this module, one is when I trying to logon on debian OpenSSH 3.8.1p1. In this situation i get the 'Permission denied', like code and debug message bellow,

use Net::SSH::Perl; my $fw = Net::SSH::Perl->new( 'server1', debug => 1 ); $fw->login( 'root','1234567890'); my ($stdout, $stderr, $exit) = $fw->cmd('ls -lh /etc'); print $stdout; ############## OUTPRINT DEBUG ######## client_win2k: Reading configuration data /.ssh/config client_win2k: Reading configuration data /etc/ssh_config client_win2k: Connecting to server1, port 22. client_win2k: Socket created, turning on blocking... client_win2k: Remote protocol version 2.0, remote software version Ope +nSSH_3.8.1p1 Debian-8.sarge.4 client_win2k: Net::SSH::Perl Version 1.29, protocol version 2.0. client_win2k: No compat match: OpenSSH_3.8.1p1 Debian-8.sarge.4. client_win2k: Connection established. client_win2k: Sent key-exchange init (KEXINIT), wait response. client_win2k: Algorithms, c->s: 3des-cbc hmac-sha1 none client_win2k: Algorithms, s->c: 3des-cbc hmac-sha1 none client_win2k: Entering Diffie-Hellman Group 1 key exchange. client_win2k: Sent DH public key, waiting for reply. client_win2k: Received host key, type 'ssh-dss'. client_win2k: Host 'server1' is known and matches the host key. client_win2k: Computing shared secret key. client_win2k: Verifying server signature. client_win2k: Waiting for NEWKEYS message. client_win2k: Enabling incoming encryption/MAC/compression. client_win2k: Send NEWKEYS, enable outgoing encryption/MAC/compression +. client_win2k: Sending request for user-authentication service. client_win2k: Service accepted: ssh-userauth. client_win2k: Trying empty user-authentication request. client_win2k: Authentication methods that can continue: publickey,keyb +oard-interactive. client_win2k: Next method to try is publickey. Permission denied at C:\Test\t.pl line 3
or... when I trying to execute a single command (Debian OpenSSH 3.0). My code stop response.
use Net::SSH::Perl; my $fw = Net::SSH::Perl->new( 'server2', debug => 1 ); $fw->login( 'root','1234567890'); my ($stdout, $stderr, $exit) = $fw->cmd('ls -lh /etc'); print $stdout; ############## OUTPRINT DEBUG ######## client_win2k: Reading configuration data /.ssh/config client_win2k: Reading configuration data /etc/ssh_config client_win2k: Connecting to server2, port 22. client_win2k: Remote protocol version 2.0, remote software version Ope +nSSH_3.0.2p1 Debian 1:3.0.2p1-9 client_win2k: Net::SSH::Perl Version 1.29, protocol version 2.0. client_win2k: No compat match: OpenSSH_3.0.2p1 Debian 1:3.0.2p1-9. client_win2k: Connection established. client_win2k: Sent key-exchange init (KEXINIT), wait response. client_win2k: Algorithms, c->s: 3des-cbc hmac-sha1 none client_win2k: Algorithms, s->c: 3des-cbc hmac-sha1 none client_win2k: Entering Diffie-Hellman Group 1 key exchange. client_win2k: Sent DH public key, waiting for reply. client_win2k: Received host key, type 'ssh-dss'. client_win2k: Permanently added 'server2' to the list of known hosts. client_win2k: Computing shared secret key. client_win2k: Verifying server signature. client_win2k: Waiting for NEWKEYS message. client_win2k: Enabling incoming encryption/MAC/compression. client_win2k: Send NEWKEYS, enable outgoing encryption/MAC/compression +. client_win2k: Sending request for user-authentication service. client_win2k: Service accepted: ssh-userauth. client_win2k: Trying empty user-authentication request. client_win2k: Authentication methods that can continue: publickey,pass +word,keyboard-interactive. client_win2k: Next method to try is publickey. client_win2k: Next method to try is password. client_win2k: Trying password authentication. client_win2k: Login completed, opening dummy shell channel. client_win2k: channel 0: new [client-session] client_win2k: Requesting channel_open for channel 0. client_win2k: channel 0: open confirm rwindow 0 rmax 16384 client_win2k: Got channel open confirmation, requesting shell. client_win2k: Requesting service shell on channel 0. client_win2k: channel 1: new [client-session] client_win2k: Requesting channel_open for channel 1. client_win2k: Entering interactive session. client_win2k: Sending command: ls -lh /etc client_win2k: Requesting service exec on channel 1. client_win2k: channel 1: open confirm rwindow 0 rmax 16384
Thanks for any help...

Solli Moreira Honorio
Sao Paulo - Brazil