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 :
- my $ssh = Net::SSH::Perl->new($host,debug => 1);
- $ssh->login($user, $pass);
- $cmd="sh version";
- (my $results, my $err, my $exit)=$ssh->cmd($cmd);
- $cmd2="sh clock";
- (my $results2, my $err, my $exit)=$ssh->cmd($cmd2);
|
Merci d'avance de votre aide.
Cordialement
Junt