Hello there,
Is there any way to make Net::OpenSSH not use multiple sessions ?
I'm trying to connect to some legacy router (therefore I have some restrictions on kex/ciphers). I try to run the following
my $ssh = Net::OpenSSH->new($ip,user=>$LOGIN,password=>$PASSWD, ssh_cmd=>'/opt/openssh/bin/ssh', master_opts => [-o => "StrictHostKeyChecking +=no", -o => "UserKnownHostsFile=/d +ev/null", -o => "NumberOfPasswordPromp +ts=1", -o => "KexAlgorithms=diffie- +hellman-group1-sha1", -o => "HostKeyAlgorithms=ssh +-dss", -o => "Ciphers=3des-cbc,blow +fish-cbc", -o => "PreferredAuthenticati +ons=keyboard-interactive,password", -o => "LogLevel=DEBUG3"]); $ssh->error and die "Can't ssh to $ip: " . $t->error; print STDERR 'Trying open2pty'."\n"; my ($fh,$pid) = $ssh->open2pty({ stderr_to_stdout => 1 }); print STDERR 'opening Telnet'."\n"; my $teln = Net::Telnet->new(Fhopen => $fh, ErrMode=>'die', timeout=>30, Dump_Log => '/tmp/telnet.log', prompt => '/(.*#)/'); $teln->login($LOGIN, $PASSWD);
Initial setup seems to follow legacy kex method.
debug2: peer server KEXINIT proposal debug2: KEX algorithms: diffie-hellman-group1-sha1 debug2: host key algorithms: ssh-dss debug2: ciphers ctos: 3des-cbc,blowfish-cbc,twofish-cbc debug2: ciphers stoc: 3des-cbc,blowfish-cbc,twofish-cbc debug2: MACs ctos: hmac-sha1,hmac-sha1-96,hmac-md5 debug2: MACs stoc: hmac-sha1,hmac-sha1-96,hmac-md5
Initial sessions get open but additional sessions after open2pty fail
debug3: channel 2: status: The following connections are open: #1 client-session (t3 r-1 i0/0 o0/0 fd 6/7 cc -1) #2 mux-control (t16 r-1 i3/0 o3/0 fd 9/9 cc -1) Trying open2pty opening Telnet debug1: multiplexing control connection debug2: fd 9 setting O_NONBLOCK debug3: fd 9 is O_NONBLOCK debug1: channel 2: new [mux-control] debug3: channel_post_mux_listener: new mux channel 2 fd 9 debug3: mux_master_read_cb: channel 2: hello sent debug3: mux_master_read_cb: channel 2 packet type 0x00000001 len 4 debug2: process_mux_master_hello: channel 2 slave version 4 debug3: mux_master_read_cb: channel 2 packet type 0x10000004 len 4 debug2: process_mux_alive_check: channel 2: alive check debug3: mux_master_read_cb: channel 2 packet type 0x10000002 len 69 debug2: process_mux_new_session: channel 2: request tty 1, X 0, agent +0, subsys 0, term "xterm-256color", cmd "", env 1 debug3: process_mux_new_session: got fds stdin 10, stdout 11, stderr 1 +2 debug1: channel 3: new [client-session] debug2: process_mux_new_session: channel_new: 3 linked to control chan +nel 2 debug2: channel 3: send open debug3: send packet: type 90 debug3: receive packet: type 91 debug2: channel 1: open confirm rwindow 12288 rmax 512 debug3: receive packet: type 1 Received disconnect from 10.10.3.6 port 22:2: Disconnect Protocol erro +r Disconnected from 10.10.3.6 port 22
Remote peer states that there is no common kex method. Shouldn't OpenSSH use only diffie-hellman-group1-sha1 here ?
WARNING 02/15/2018 22:59:00 UTC/GMT ssh: no supported key exchange met +hod (curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp25 +6,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange +-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,d +iffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffi +e-hellman-group14-sha1,ext-info-c) DEBUG 02/15/2018 22:59:00 UTC/GMT ssh: sent msg type 1, 48 bytes
When I try cli openssh client it opens only one channel and there is no problem.
I appreciate any clue how to workaround this issue. The one that comes to my mind is to use Expect and cli ssh client but I would like to avoid it if possible.
Forgive me this little too long post.
Regards,
Pawel

In reply to Net::OpenSSH multiple sessions and legacy KEX problem by pwlodawi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.