SSH Module: Accessing CLI box using SSH and not getting the return output??

D

Deepika

Hi Everyone,

I am trying to write a perl code to access and run few commands on a
Secure CLI-Box using SSH module in Perl.After installing the Perl
module with a lot of difficulty I am facing the following issue. I am
able to log-into the box but I don't get any results back for the
commands I am trying to run on the box.
If I use the same perl code to log-into another linux machine and do
an"ls" I get the result back with no problems at all. Here is the debug
message while trying to access the CLI-box and running the commands.

Any Help will be really appreciated. I have been struck at the same
issue for about a month and my code is due soon and I have no clue how
to fix it.

[root@deepika-linux ~]# cd rnc
[root@deepika-linux rnc]# perl ss.pl
deepika-linux: Reading configuration data /root/.ssh/config
deepika-linux: Reading configuration data /etc/ssh_config
deepika-linux: Allocated local port 1023.
deepika-linux: Connecting to xx.xx.xx.xx, port 22.
deepika-linux: Remote version string: SSH-2.0-OpenSSH_3.5p1

deepika-linux: Remote protocol version 2.0, remote software version
OpenSSH_3.5p1
deepika-linux: Net::SSH::perl Version 1.30, protocol version 2.0.
deepika-linux: No compat match: OpenSSH_3.5p1.
deepika-linux: Connection established.
deepika-linux: Sent key-exchange init (KEXINIT), wait response.
deepika-linux: Algorithms, c->s: 3des-cbc hmac-sha1 none
deepika-linux: Algorithms, s->c: 3des-cbc hmac-sha1 none
deepika-linux: Entering Diffie-Hellman Group 1 key exchange.
deepika-linux: Sent DH public key, waiting for reply.
deepika-linux: Received host key, type 'ssh-dss'.
deepika-linux: Host 'xx.xx.xx.xx' is known and matches the host key.
deepika-linux: Computing shared secret key.
deepika-linux: Verifying server signature.
deepika-linux: Waiting for NEWKEYS message.
deepika-linux: Enabling incoming encryption/MAC/compression.
deepika-linux: Send NEWKEYS, enable outgoing
encryption/MAC/compression.
deepika-linux: Sending request for user-authentication service.
deepika-linux: Service accepted: ssh-userauth.
deepika-linux: Trying empty user-authentication request.
deepika-linux: Authentication methods that can continue: password.
deepika-linux: Next method to try is password.
deepika-linux: Trying password authentication.

value of stdout = 1

value of stderr =

value of exitt =
deepika-linux: channel 0: new [client-session]
deepika-linux: Requesting channel_open for channel 0.
deepika-linux: Entering interactive session.
deepika-linux: Sending command: ?
deepika-linux: Requesting service exec on channel 0.
deepika-linux: channel 0: open confirm rwindow 0 rmax 32768

value of stdout =
value of stderr =
value of exitt =
[root@deepika-linux rnc]#

Thanks and will wait for the response.
 
J

J. Gleixner

Deepika said:
Hi Everyone,

I am trying to write a perl code to access and run few commands on a
Secure CLI-Box using SSH module in Perl.After installing the Perl
module with a lot of difficulty I am facing the following issue. I am
able to log-into the box but I don't get any results back for the
commands I am trying to run on the box.
If I use the same perl code to log-into another linux machine and do
an"ls" I get the result back with no problems at all. Here is the debug
message while trying to access the CLI-box and running the commands.

Any Help will be really appreciated. I have been struck at the same
issue for about a month and my code is due soon and I have no clue how
to fix it.

Showing your code would help.

First, run the ssh from the command line:

ssh machine ls

Does that work for both machines?
 
D

Deepika

Hi ,

Thanks a lot for responding back. My code is really straightforward (as
easy as it can get):

use Net::SSH::perl;
my $test = "xx.xx.xx.xx";
%params = ("debug",true);
my $sshtest = Net::SSH::perl->new($test,%params);
my ($stdout, $stderr, $exit) = $sshtest->login("username","password");
print "\n value of stdout = $stdout \n";
print "\n value of stderr = $stderr \n";
print "\n value of exitt = $exit \n";
($stdout, $stderr, $exit) = $sshtest->cmd("?");
print "\n value of stdout = $stdout \n";
print "value of stderr = $stderr \n";
print "value of exitt = $exit \n";

Also running an ssh from the command line works. When I do an:
ssh user@ipaddress I actually enter the CLI session for the RNC(device
I am trying to access,like entering a Cisco switch) and can now enter
any commands.
If I run my script to enter the same commands, I don't get a reply
back.On the CLI manager I can't do an "ls" but I have tried various
commands and none of them come back with any output.

But as I mentioned if I use the same script above to access any other
linux box and do an ls command I actually see the output back.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top