RE: [Ssh-sftp-perl-users] Interfacing with network appliance through ssh
Brought to you by:
dbrobins
From: Matthew J. S. <vag...@ya...> - 2006-03-23 23:23:00
|
I think I might have found part of the problem, maybe... When you call: $ssh->cmd("$cmd"); I believe that it waits for an exit code from whatever it is executing. In my case, I am not executing anything, therefore I wont receive an exit code. I guess that I need to setup my own channel and not use $ssh->cmd. I can't be the only preson who has come across a situation like this. Anyone have any suggestions? Here is what the putty logs look like: <Just hit enter after entering username> Outgoing packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) Incoming packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) ..........Password: Outgoing packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) Incoming packet type 2 / 0x02 (SSH2_MSG_IGNORE) --- "Matthew J. Salerno" <vag...@ya...> wrote: > If I use Data::Dumper to view the buffer, I see that > what gets returned is an already failed > authentication > attempt. Is there anything else I should check? > > Thanks, > > Matt > > my $i = 0; > > $ssh->register_handler("stdout", sub { > $i++; > my($channel, $buffer) = @_; > print Dumper $buffer; > my $str = $buffer->bytes; > my $getsrt = $buffer->get_str; > print "\nSTR $i: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER $i\n"; > $channel->send_data("$user\n"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD $i\n"; > $channel->send_data("$pw"); > } > }); > > my ($stdout, $stderr, $exit) = $ssh->cmd($user); > > Output: > > > Logging In > $VAR1 = bless( { > '_get_mp_int' => sub { "DUMMY" }, > '_put_mp_int' => sub { "DUMMY" }, > 'buf' => 'Welcome to Webstream > Server > > Username: ', > 'offset' => 0 > }, 'Net::SSH::Perl::Buffer' ); > > STR 1: Welcome to Webstream Server > > Username: > END > > USER 1 > $VAR1 = bless( { > '_get_mp_int' => sub { "DUMMY" }, > '_put_mp_int' => sub { "DUMMY" }, > 'buf' => 'Password: > Could not read password. > Authenticating [username2]..... > Authentication Failed. Good bye. [0x9] > ', > 'offset' => 0 > }, 'Net::SSH::Perl::Buffer' ); > > STR 2: Password: > Could not read password. > Authenticating [username2]..... > Authentication Failed. Good bye. [0x9] > > END > > > PASSWORD 2 > EXIT 255 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |