SSH Erreur lors de la connexion

SSH Erreur lors de la connexion - Perl - Programmation

Marsh Posté le 24-02-2008 à 14:37:41    

Bonjour à tous,  
J'essaye en perl de réaliser un script qui se connecte sur un équipement et exécute 2 commandes sh version et sh clock.
1) Cela fonctionne mais j'ai tout de même un warning d'erreur lorsque je me connecte(voir messages en gras).
2) Enfin j'aimerais rester connecté pour l'execution de ces 2 commandes. Or dans le débug on peut voir qu'il se connecte 1 fois pour chacune.
 
 
localhost.localdomain: Reading configuration data /root/.ssh/config
localhost.localdomain: Reading configuration data /etc/ssh_config
localhost.localdomain: Allocated local port 1023.
localhost.localdomain: Connecting to 192.168.205.254, port 22.
localhost.localdomain: Remote version string: SSH-1.99-Cisco-1.25
 
localhost.localdomain: Remote protocol version 1.99, remote software version Cisco-1.25
localhost.localdomain: Net::SSH::Perl Version 1.30, protocol version 1.5.
localhost.localdomain: No compat match: Cisco-1.25.
localhost.localdomain: Connection established.
localhost.localdomain: Waiting for server public key.
localhost.localdomain: Received server public key (640 bits) and host key (768 bits).
Argument "ssh-rsa" isn't numeric in numeric eq (==) at /usr/lib/perl5/vendor_perl/5.8.8/Net/SSH/Perl/Key/RSA1.pm line 94, <FH> line 1.
localhost.localdomain: Host '192.168.205.254' is known and matches the host key.
localhost.localdomain: Encryption type: DES3
localhost.localdomain: Sent encrypted session key.
localhost.localdomain: Received encryption confirmation.
localhost.localdomain: Trying password authentication.
localhost.localdomain: Sending command: sh ip arp vrf Client1
localhost.localdomain: Entering interactive session.
localhost.localdomain: Allocated local port 1022.
localhost.localdomain: Connecting to 192.168.205.254, port 22.
localhost.localdomain: Remote version string: SSH-1.99-Cisco-1.25
 
localhost.localdomain: Remote protocol version 1.99, remote software version Cisco-1.25
localhost.localdomain: Net::SSH::Perl Version 1.30, protocol version 1.5.
localhost.localdomain: No compat match: Cisco-1.25.
localhost.localdomain: Connection established.
localhost.localdomain: Waiting for server public key.
localhost.localdomain: Received server public key (640 bits) and host key (768 bits).
Argument "ssh-rsa" isn't numeric in numeric eq (==) at /usr/lib/perl5/vendor_perl/5.8.8/Net/SSH/Perl/Key/RSA1.pm line 94, <FH> line 1.
localhost.localdomain: Host '192.168.205.254' is known and matches the host key.
localhost.localdomain: Encryption type: DES3
localhost.localdomain: Sent encrypted session key.
localhost.localdomain: Received encryption confirmation.
localhost.localdomain: Trying password authentication.
localhost.localdomain: Sending command: sh clock
localhost.localdomain: Entering interactive session.
 
Voici mon script:  

Code :
  1. my $ssh = Net::SSH::Perl->new($host,debug => 1);
  2.         $ssh->login($user, $pass);
  3.        $cmd="sh version";
  4.        (my $results, my $err, my $exit)=$ssh->cmd($cmd);
  5.        $cmd2="sh clock";
  6.        (my $results2, my $err, my $exit)=$ssh->cmd($cmd2);


 
Merci d'avance de votre aide.
Cordialement
Junt

Reply

Marsh Posté le 24-02-2008 à 14:37:41   

Reply

Marsh Posté le 24-02-2008 à 15:20:40    

Pour ce qui est des connexions multiples, la doc dit que c'est le cas en SSH1
[url]http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.30/lib/Net/SSH/Perl.pm#($out,_$err,_$exit)_=_$ssh-%3Ecmd($cmd,_[_$stdin_])[/url]

Citation :


If $stdin is provided, it's supplied to the remote command $cmd on standard input.
 
NOTE: the SSH-1 protocol does not support running multiple commands per connection, unless those commands are chained together so that the remote shell can evaluate them. Because of this, a new socket connection is created each time you call cmd, and disposed of afterwards. In other words, this code:
 
    my $ssh = Net::SSH::Perl->new("host1" );
    $ssh->login("user1", "pass1" );
 
    $ssh->cmd("foo" );
    $ssh->cmd("bar" );
 
will actually connect to the sshd on the first invocation of cmd, then disconnect; then connect again on the second invocation of cmd, then disconnect again.
 
Note that this does not apply to the SSH-2 protocol. SSH-2 fully supports running more than one command over the same connection.


Message édité par dreameddeath le 24-02-2008 à 15:21:24
Reply

Marsh Posté le 24-02-2008 à 17:43:36    

Hello,  
Merci dreameddeath pour tes explications.
Après avoir fait le point des problèmes rencontrés sur le Net, il s'avère que  de nombreuses personnes ont des soucis avec les modules perl ssh ( authentification trop longue etc..) J'ai finalement utiliser un autre module qui permet de faire aussi bien les connexions telnet que SSH et qui fonctionne très bien !
Merci  
A+
Junt

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed