Re: [Ssh-sftp-perl-users] Device does not support shell requestnotpreceded by pty request
Brought to you by:
dbrobins
From: Heinrich, M. <Mat...@sa...> - 2006-11-28 19:04:33
|
It may be a bug / feature of your HP Procurve... I wonder if it = interpreted the channel 0 shell request as the actual shell request.... Normally, when I look at the debug output, right after "Entering = interactive sessions", my client will request a pty and then the shell. Can you manually get on with ssh? What do you see from the debug output = of: ssh -vvv -l operator 10.1.2.22 ? -----Original Message----- From: DonKiShoot [mailto:don...@wa...]=20 Sent: Tuesday, November 28, 2006 3:48 AM To: Heinrich, Matthew Cc: ssh...@li... Subject: Re: [Ssh-sftp-perl-users] Device does not support shell = requestnotpreceded by pty request Thank you very much for your response. Your solution seems to be a bit more complex but i decided to try it = because i don't want to remain on a failure ;) First, i used this script to join my hp procurve 2650 as you suggest me = : #!/usr/bin/perl -w use strict; use Net::SSH::Perl; my $ssh =3D Net::SSH::Perl->new('10.1.2.22','debug' =3D> 1); = $ssh->login('operator'); $ssh->shell(); But, i've always got the same bug : [root@srv78supervision ~]# ./connect.pl srv78supervision: Reading configuration data /root/.ssh/config srv78supervision: Reading configuration data /etc/ssh_config srv78supervision: Allocated local port 1023. srv78supervision: Connecting to 10.1.2.22, port 22. srv78supervision: Remote version string: SSH-2.0-OpenSSH_3.7.1p2 srv78supervision: Remote protocol version 2.0, remote software version OpenSSH_3.7.1p2 srv78supervision: Net::SSH::Perl Version 1.30, protocol version 2.0. srv78supervision: No compat match: OpenSSH_3.7.1p2. srv78supervision: Connection established. srv78supervision: Sent key-exchange init (KEXINIT), wait response. srv78supervision: Algorithms, c->s: 3des-cbc hmac-sha1 none srv78supervision: Algorithms, s->c: 3des-cbc hmac-sha1 none srv78supervision: Entering Diffie-Hellman Group 1 key exchange. srv78supervision: Sent DH public key, waiting for reply. srv78supervision: Received host key, type 'ssh-rsa'. srv78supervision: Host '10.1.2.22' is known and matches the host key. srv78supervision: Computing shared secret key. srv78supervision: Verifying server signature. srv78supervision: Waiting for NEWKEYS message. srv78supervision: Enabling incoming encryption/MAC/compression. srv78supervision: Send NEWKEYS, enable outgoing = encryption/MAC/compression. srv78supervision: Sending request for user-authentication service. srv78supervision: Service accepted: ssh-userauth. srv78supervision: Trying empty user-authentication request. srv78supervision: Authentication methods that can continue:=20 publickey,password. srv78supervision: Next method to try is publickey. srv78supervision: Trying pubkey authentication with key file = '/root/.ssh/id_dsa' srv78supervision: Login completed, opening dummy shell channel. srv78supervision: channel 0: new [client-session] srv78supervision: Requesting channel_open for channel 0. srv78supervision: channel 0: open confirm rwindow 0 rmax 32768 srv78supervision: Got channel open confirmation, requesting shell. srv78supervision: Requesting service shell on channel 0. srv78supervision: channel 1: new [client-session] srv78supervision: Requesting channel_open for channel 1. srv78supervision: Entering interactive session. Received disconnect message: Device does not support shell request not = preceded by pty request. at /usr/lib/perl5/vendor_perl/5.8.8/Net/SSH/Perl/SSH2.pm line 284 Do you think that this bug come from HP Procurve 2650 ? It's not my first problem with this material (storm broadcasting for = exemple), i believe that this IOS is a piece of chit !!! No more idea ? Must i give up ? Heinrich, Matthew a =E9crit : > =20 > > Looks like some of the formatting got messed up in transit... =20 > > > -----Original Message----- > From: ssh...@li... > [mailto:ssh...@li...] On Behalf=20 > Of Heinrich, Matthew > Sent: Monday, November 27, 2006 4:52 PM > To: DonKiShoot; ssh...@li... > Subject: Re: [Ssh-sftp-perl-users] Device does not support shell=20 > requestnotpreceded by pty request > > I have been working on the same sort of problem for a while now. I=20 > was getting this same error because the "cmd" function of=20 > Net::SSH::Perl will always expect an exit code, and the devices to=20 > which we are communicating do not support exit codes after each=20 > command. Also, the device prefers to have all commands sent through=20 > the same channel, and Net::SSH::Perl will open a new channel for each=20 > command when using SSHv2. > > At first, I tried copying "sub cmd" to "sub ccmd" and making it use=20 > the same channel, but I could not get the buffers to work properly. A = > lot of people said to use an Expect script, but that didn't seem like=20 > good idea, until I took a look at the Expect Perl module... > > I created a connecting script (connect.pl) which will login and get me = > to an interactive prompt: > > ---------------------------------------------------------------------- > -- > -------- > #!/usr/bin/perl > > use strict; > use Net::SSH::Perl; > > my $host =3D "a.b.c.d"; > my $user =3D "uname"; > my $pass =3D "pword"; > > my $ssh =3D Net::SSH::Perl->new($host, port=3D>22); $ssh->login($user, = > $pass); $ssh->shell(); > ---------------------------------------------------------------------- > -- > -------- > > > Next, I created the main Perl script using the Expect module, spawning = > this connection program: > > > ---------------------------------------------------------------------- > -- > -------- > #!/usr/bin/perl > > use Expect; > > $| =3D 1; # Auto flush output > > my $exp =3D Expect->new(); > > # Prevent local echo from showing in results $exp->raw_pty(1); > > # Run connector program > $exp->spawn("./connect.pl"); > > # Prevent output from going to STDOUT > (*$exp)->{exp_Log_Stdout} =3D 0; > > # Wait for initial prompt (30 sec timeout) $exp->expect(30,=20 > "centerpoint>"); > > # Send command with no output needed > snd("set rows 0"); > > print "Sending remote command..."; > > # Send command, store output in @res array @res =3D snd("show vss"); > > print "OK\n\nResults:\n"; > > # List output line-by-line > foreach $n (0..$#res) { > print "$n: @res[$n]\n"; > } > > $exp->send("exit\n"); > $exp->soft_close(); > > # This makes sending multiple commands much easier. Instead of #=20 > using multiple "send" and "expect" calls manually, just use snd > > sub snd ($){ > $exp->send(@_[0] . "\n"); > > # Use the "-re" option to specify regular expression, as > # opposed to an exact pattern match. Otherwise, you can=20 > # just list 2 arguments (timeout, pattern match) > my @out =3D $exp->expect(10, "-re", 'centerpoint>$'); > my @newout =3D split(/\n/, @out[3]); > > # Remove first line (in my case, it shows the command I typed, > # which is not needed in the resulting output) > shift @newout; > > return wantarray ? @newout : 1; } > ---------------------------------------------------------------------- > -- > -------- > > > This script will wait for connect.pl to present the CLI prompt (in=20 > this case, it shows "centerpoint>"), and will be able to interact with = > the SSH session more easily than if you modified Net::SSH::Perl, or if = > you used TCL Expect. > > > -----Original Message----- > From: ssh...@li... > [mailto:ssh...@li...] On Behalf=20 > Of DonKiShoot > Sent: Wednesday, November 22, 2006 8:16 AM > To: ssh...@li... > Subject: Re: [Ssh-sftp-perl-users] Device does not support shell=20 > request notpreceded by pty request > > Hello all, > > I'm trying to send some commands to my switch HP Procurve 2650 in ssh2 = > with Net::SSH::Perl with user 'operator' and pubkey authentification. > It appears that i have a problem when starting to send command but=20 > authentification seems good. > > This is sample of my perl script and next debug trace with error i > receive: > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > foreach my $addr (keys %Switch) { > # print "$addr, $Switch{$addr}{'login'} :\n"; > my $ssh =3D Net::SSH::Perl->new($addr,'debug' =3D> 1, 'use_pty' = =3D> 1,=20 > 'protocol' =3D> 2, 'interactive' =3D> 0, options =3D> = ["RhostsAuthentication=20 > no"]); > > #$ssh->register_handler("stdout", sub { > # my($channel, $buffer) =3D @_; > # print "I received this: ", $buffer->bytes; > # }); > > $ssh->login($Switch{$addr}{'login'}); > > my($stdout, $stderr, $exit) =3D $ssh->cmd("\n"); > print "$stdout $stderr $exit\n"; > ($stdout, $stderr, $exit) =3D $ssh->cmd("ping $ip"); > print "$stdout $stderr $exit\n"; > } > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > srv78supervision: Reading configuration data /root/.ssh/config > srv78supervision: Reading configuration data /etc/ssh_config > srv78supervision: Allocated local port 1023. > srv78supervision: Connecting to 10.1.2.22, port 22. > srv78supervision: Remote version string: SSH-2.0-OpenSSH_3.7.1p2 > > srv78supervision: Remote protocol version 2.0, remote software version > OpenSSH_3.7.1p2 > srv78supervision: Net::SSH::Perl Version 1.30, protocol version 2.0. > srv78supervision: No compat match: OpenSSH_3.7.1p2. > srv78supervision: Connection established. > srv78supervision: Sent key-exchange init (KEXINIT), wait response. > srv78supervision: Algorithms, c->s: 3des-cbc hmac-sha1 none > srv78supervision: Algorithms, s->c: 3des-cbc hmac-sha1 none > srv78supervision: Entering Diffie-Hellman Group 1 key exchange. > srv78supervision: Sent DH public key, waiting for reply. > srv78supervision: Received host key, type 'ssh-rsa'. > srv78supervision: Host '10.1.2.22' is known and matches the host key. > srv78supervision: Computing shared secret key. > srv78supervision: Verifying server signature. > srv78supervision: Waiting for NEWKEYS message. > srv78supervision: Enabling incoming encryption/MAC/compression. > srv78supervision: Send NEWKEYS, enable outgoing=20 > encryption/MAC/compression. > srv78supervision: Sending request for user-authentication service. > srv78supervision: Service accepted: ssh-userauth. > srv78supervision: Trying empty user-authentication request. > srv78supervision: Authentication methods that can continue:=20 > publickey,password. > srv78supervision: Next method to try is publickey. > srv78supervision: Trying pubkey authentication with key file=20 > '/root/.ssh/id_dsa' > srv78supervision: Login completed, opening dummy shell channel. > srv78supervision: channel 0: new [client-session] > srv78supervision: Requesting channel_open for channel 0. > srv78supervision: channel 0: open confirm rwindow 0 rmax 32768 > srv78supervision: Got channel open confirmation, requesting shell. > srv78supervision: Requesting service shell on channel 0. > srv78supervision: channel 1: new [client-session] > srv78supervision: Requesting channel_open for channel 1. > srv78supervision: Entering interactive session. > /*Received disconnect message: Device does not support shell request=20 > not preceded by pty request. > at /usr/lib/perl5/vendor_perl/5.8.8/Net/SSH/Perl/SSH2.pm line 284*/ > > What can i do to resolve this problem ? > > Thx all > > > > > ---------------------------------------------------------------------- > -- > - > Take Surveys. Earn Cash. Influence the Future of IT Join=20 > SourceForge.net's Techsay panel and you'll get the chance to share=20 > your opinions on IT & business topics through brief surveys - and earn = > cash=20 > = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEV > DE > V > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > ---------------------------------------------------------------------- > -- > - > Take Surveys. Earn Cash. Influence the Future of IT Join=20 > SourceForge.net's Techsay panel and you'll get the chance to share=20 > your opinions on IT & business topics through brief surveys - and earn = > cash=20 > = http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEV > DE > V > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > =20 |