Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

net::ssh::perl : no way to send cmd !

by coldroom (Novice)
on Feb 01, 2010 at 13:58 UTC ( [id://820742]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,

My perl script has to connect a dlink switch and get config back to a tftp server.

Here's the connexion log :

tri-srv-jh: Reading configuration data /home/julian/.ssh/config tri-srv-jh: Reading configuration data /etc/ssh_config tri-srv-jh: Connecting to 10.0.0.30, port 22. tri-srv-jh: Remote protocol version 2.0, remote software version DLINK + Corp. SSH server ver 1.00.000 tri-srv-jh: Net::SSH::Perl Version 1.34, protocol version 2.0. tri-srv-jh: No compat match: DLINK Corp. SSH server ver 1.00.000. tri-srv-jh: Connection established. tri-srv-jh: Sent key-exchange init (KEXINIT), wait response. tri-srv-jh: Algorithms, c->s: 3des-cbc hmac-sha1 none tri-srv-jh: Algorithms, s->c: 3des-cbc hmac-sha1 none tri-srv-jh: Entering Diffie-Hellman Group 1 key exchange. tri-srv-jh: Sent DH public key, waiting for reply. tri-srv-jh: Received host key, type 'ssh-dss'. tri-srv-jh: Host '10.0.0.30' is known and matches the host key. tri-srv-jh: Computing shared secret key. tri-srv-jh: Verifying server signature. tri-srv-jh: Waiting for NEWKEYS message. tri-srv-jh: Send NEWKEYS. tri-srv-jh: Enabling encryption/MAC/compression. tri-srv-jh: Sending request for user-authentication service. tri-srv-jh: Service accepted: ssh-userauth. tri-srv-jh: Trying empty user-authentication request. tri-srv-jh: Authentication methods that can continue: password. tri-srv-jh: Next method to try is password. tri-srv-jh: Trying password authentication. tri-srv-jh: Login completed, opening dummy shell channel. tri-srv-jh: channel 0: new [client-session] tri-srv-jh: Requesting channel_open for channel 0. tri-srv-jh: channel 0: open confirm rwindow 10000 rmax 8192 tri-srv-jh: Got channel open confirmation, requesting shell. tri-srv-jh: Requesting service shell on channel 0. tri-srv-jh: channel 1: new [client-session] tri-srv-jh: Requesting channel_open for channel 1. tri-srv-jh: Entering interactive session. ^C

As you can see, I have to do a ctrl+c to leave session. In fact, after "Entering interactive session." ... nothing, the abyss.

I tryed a lot of things to send my command, but noway :(

Here's my source code :

sub Recup_dlink_DGS { #$ssh = Net::SSH::Perl -> new(@switch_details[1]); #$ssh->login(@switch_details[4], @switch_details[3]); #$ssh->cmd("upload cfg_toTFTP $serveur_tftp @switch_details[2] +")"; #sleep 2; #$cmd = "upload cfg_toTFTP $serveur_tftp @switch_details[2]"; my %params = ( protocol => 2, debug => "true"); $ssh = Net::SSH::Perl->new(@switch_details[1], %params); $ssh->login(@switch_details[4], @switch_details[3]); #my ($stdout, $stderr, $exit) = $ssh->cmd($cmd); #print $stdout . "\n"; #print $stderr . "\n"; #print $exit . "\n"; $ssh->cmd("upload cfg_toTFTP $serveur_tftp @switch_details[2]" +); #&controle_cfg; #return 1; }

Can you help me please ? You have to know that i can't use telnet or expect for the moment.

Many thanks

j.

Replies are listed 'Best First'.
Re: net::ssh::perl : no way to send cmd !
by salva (Canon) on Feb 01, 2010 at 14:16 UTC
      Hello,

      Thanks for your answer, but I already tryed with expect.. look at this :

      SSHAuthenticationError Login timed out. The input stream currently has the contents bellow: RW@10.0.0.30's password:  at /usr/local/share/perl/5.10.1/Expect.pm line 828

      When I use this :

      print ("login : @switch_details[4] \n"); print ("password : @switch_details[3]\n"); my $ssh = Net::SSH::Expect->new ( host => @switch_details[1], password=> @switch_details[3], user => @switch_details[4], raw_pty => 1 ); my $login_output = $ssh->login();

      My login & password are good..

      If I try to use net::ssh::perl, there is a bug, and now, with expect, bug too.. I don't know how doing that :(
        what happens when you try to run the same command from the command line?
        $ ssh -vvv user@your.switch upload cfg_toTFTP ...

      Have u got any fix for the question as i too getting same error

      linux1642: Verifying server signature. linux1642: Waiting for NEWKEYS message. linux1642: Enabling incoming encryption/MAC/compression. linux1642: Send NEWKEYS, enable outgoing encryption/MAC/compression. linux1642: Sending request for user-authentication service. linux1642: Service accepted: ssh-userauth. linux1642: Trying empty user-authentication request. linux1642: Authentication methods that can continue: password,publickey,keyboard-interactive. linux1642: Next method to try is password. linux1642: Trying password authentication. linux1642: Authentication methods that can continue: password,publickey,keyboard-interactive. linux1642: Next method to try is password. linux1642: Trying password authentication. linux1642: Authentication methods that can continue: password,publickey,keyboard-interactive. linux1642: Next method to try is password. linux1642: Trying password authentication. Received disconnect message: Too many bad authentication attempts! at /usr/lib/perl5/site_perl/5.8.5/Net/SSH/Perl/AuthMgr.pm line 143

      can any one help on this as most of times not connecting , but rarely connecting.

      Thanks Sudheer

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-03-19 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found