Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh2.sh test failed with OpenSSH 8.8p1 #630

Closed
icebluey opened this issue Oct 5, 2021 · 15 comments
Closed

ssh2.sh test failed with OpenSSH 8.8p1 #630

icebluey opened this issue Oct 5, 2021 · 15 comments

Comments

@icebluey
Copy link

icebluey commented Oct 5, 2021

libssh2 version: 1.9.0 and 1.10.0

[root@localhost]# make check
...
PASS: simple
PASS: mansyntax.sh
FAIL: ssh2.sh
============================================================================
Testsuite summary for libssh2 -
============================================================================
# TOTAL: 3
# PASS:  2
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to libssh2-devel@cool.haxx.se
============================================================================



[root@localhost]# cat tests/test-suite.log
=====================================
   libssh2 -: tests/test-suite.log
=====================================

# TOTAL: 3
# PASS:  2
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: ssh2.sh
=============

command-line line 0: Deprecated option UsePrivilegeSeparation
command-line line 0: Deprecated option UsePrivilegeSeparation
Failure establishing SSH session
FAIL ssh2.sh (exit status: 1)

[root@localhost]# ssh -V
OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021

@willco007
Copy link
Member

Could you add the error output to this report or the ssh error logs?

@icebluey
Copy link
Author

icebluey commented Oct 5, 2021

Error output in logfile:

sshd[906]: Server listening on 0.0.0.0 port 4764.
sshd[906]: Server listening on :: port 4764.
sshd[906]: Received signal 15; terminating.
sshd[937]: Unable to negotiate with 127.0.0.1 port 18162: no matching host key type found. Their offer: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-rsa,ssh-dss [preauth]

@kanavin
Copy link

kanavin commented Oct 19, 2021

Seeing this in local testing as well.

root@qemux86-64:/usr/lib/libssh2/ptest/tests# DEBUG=1 ./ssh2.sh 
command-line line 0: Deprecated option UsePrivilegeSeparation
debug2: load_server_config: filename /dev/null
debug2: load_server_config: done config len = 1
debug2: parse_server_config_depth: config /dev/null len 1
debug1: sshd version OpenSSH_8.8, OpenSSL 3.0.0 7 sep 2021
debug1: private host key #0: ssh-rsa SHA256:vYc4H82Dsul0alhutVzAnUmjUibvKXoHWY022QWJbxs
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-f'
debug1: rexec_argv[2]='/dev/null'
debug1: rexec_argv[3]='-h'
debug1: rexec_argv[4]='/usr/lib/libssh2/ptest/tests/etc/host'
debug1: rexec_argv[5]='-o'
debug1: rexec_argv[6]='Port 4711'
debug1: rexec_argv[7]='-o'
debug1: rexec_argv[8]='Protocol 2'
debug1: rexec_argv[9]='-o'
debug1: rexec_argv[10]='AuthorizedKeysFile /usr/lib/libssh2/ptest/tests/etc/user.pub'
debug1: rexec_argv[11]='-o'
debug1: rexec_argv[12]='UsePrivilegeSeparation no'
debug1: rexec_argv[13]='-o'
debug1: rexec_argv[14]='StrictModes no'
debug1: rexec_argv[15]='-D'
debug1: rexec_argv[16]='-d'
debug1: rexec_argv[17]='-d'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 4711 on 0.0.0.0.
Server listening on 0.0.0.0 port 4711.
debug2: fd 4 setting O_NONBLOCK
debug1: Bind to port 4711 on ::.
Server listening on :: port 4711.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
command-line line 0: Deprecated option UsePrivilegeSeparation
debug2: parse_server_config_depth: config rexec len 1
debug1: sshd version OpenSSH_8.8, OpenSSL 3.0.0 7 sep 2021
debug1: private host key #0: ssh-rsa SHA256:vYc4H82Dsul0alhutVzAnUmjUibvKXoHWY022QWJbxs
debug1: inetd sockets after dupping: 3, 3
Connection from 127.0.0.1 port 57322 on 127.0.0.1 port 4711 rdomain ""
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version libssh2_1.10.0
debug1: compat_banner: no match: libssh2_1.10.0
debug2: fd 3 setting O_NONBLOCK
debug2: Network child is on pid 2438
debug1: permanently_set_uid: 998/998 [preauth]
debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
Failure establishing SSH session
debug1: SSH2_MSG_KEXINIT received [preauth]
debug2: local server KEXINIT proposal [preauth]
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-]
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256 [preauth]
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth]
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth]
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h]
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h]
debug2: compression ctos: none,zlib@openssh.com [preauth]
debug2: compression stoc: none,zlib@openssh.com [preauth]
debug2: languages ctos:  [preauth]
debug2: languages stoc:  [preauth]
debug2: first_kex_follows 0  [preauth]
debug2: reserved 0  [preauth]
debug2: peer client KEXINIT proposal [preauth]
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-]
debug2: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.co]
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc [preauth]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc [preauth]
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth]
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth]
debug2: compression ctos: none [preauth]
debug2: compression stoc: none [preauth]
debug2: languages ctos:  [preauth]
debug2: languages stoc:  [preauth]
debug2: first_kex_follows 0  [preauth]
debug2: reserved 0  [preauth]
debug1: kex: algorithm: curve25519-sha256 [preauth]
debug1: kex: host key algorithm: (no match) [preauth]
Unable to negotiate with 127.0.0.1 port 57322: no matching host key type found. Their offer: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: Killing privsep child 2438

@willco007
Copy link
Member

Which test is failing? These logs show different types of failures.

@kanavin
Copy link

kanavin commented Oct 19, 2021

ssh2.sh is the failing test in all of them, I'm just running it manually in a standalone target install. And the issue seems similar too:

Unable to negotiate with 127.0.0.1 port 57322: no matching host key type found. Their offer: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp]

@willco007
Copy link
Member

We are only offering curve25519-sha256 instead of matching what the server is offering in the key exchange. I'm not sure why/how this would have changed. I don't have Docker set up on this machine at the moment, but it should be possible to see what's happening by looking at kex_agree_instr.

@icebluey icebluey changed the title make check failed with OpenSSH 8.8p1 ssh2.sh test failed with OpenSSH 8.8p1 Oct 25, 2021
@willco007
Copy link
Member

OK, in the first report the server is only offering rsa-sha2-512,rsa-sha2-256 host keys which aren't supported yet. In 8.8 OpenSSH disabled sha1 rsa-sha keys out of the box which is why this is all of a sudden failing. There is a PR to add support here #626. Could one of you try that PR to make sure it fixes this issue before I land it? Thanks!

@kanavin
Copy link

kanavin commented Oct 26, 2021

Some progress but not there yet.

root@qemux86-64:/usr/lib/libssh2/ptest/tests# DEBUG=1 ./ssh2.sh 
command-line line 0: Deprecated option UsePrivilegeSeparation
debug2: load_server_config: filename /dev/null
debug2: load_server_config: done config len = 1
debug2: parse_server_config_depth: config /dev/null len 1
debug1: sshd version OpenSSH_8.8, OpenSSL 3.0.0 7 sep 2021
debug1: private host key #0: ssh-rsa SHA256:vYc4H82Dsul0alhutVzAnUmjUibvKXoHWY022QWJbxs
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-f'
debug1: rexec_argv[2]='/dev/null'
debug1: rexec_argv[3]='-h'
debug1: rexec_argv[4]='/usr/lib/libssh2/ptest/tests/etc/host'
debug1: rexec_argv[5]='-o'
debug1: rexec_argv[6]='Port 4711'
debug1: rexec_argv[7]='-o'
debug1: rexec_argv[8]='Protocol 2'
debug1: rexec_argv[9]='-o'
debug1: rexec_argv[10]='AuthorizedKeysFile /usr/lib/libssh2/ptest/tests/etc/user.pub'
debug1: rexec_argv[11]='-o'
debug1: rexec_argv[12]='UsePrivilegeSeparation no'
debug1: rexec_argv[13]='-o'
debug1: rexec_argv[14]='StrictModes no'
debug1: rexec_argv[15]='-D'
debug1: rexec_argv[16]='-d'
debug1: rexec_argv[17]='-d'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 4711 on 0.0.0.0.
Server listening on 0.0.0.0 port 4711.
debug2: fd 4 setting O_NONBLOCK
debug1: Bind to port 4711 on ::.
Server listening on :: port 4711.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
command-line line 0: Deprecated option UsePrivilegeSeparation
debug2: parse_server_config_depth: config rexec len 1
debug1: sshd version OpenSSH_8.8, OpenSSL 3.0.0 7 sep 2021
debug1: private host key #0: ssh-rsa SHA256:vYc4H82Dsul0alhutVzAnUmjUibvKXoHWY022QWJbxs
debug1: inetd sockets after dupping: 3, 3
Connection from 127.0.0.1 port 59872 on 127.0.0.1 port 4711 rdomain ""
debug1: Local version string SSH-2.0-OpenSSH_8.8
debug1: Remote protocol version 2.0, remote software version libssh2_1.9.0_DEV
debug1: compat_banner: no match: libssh2_1.9.0_DEV
debug2: fd 3 setting O_NONBLOCK
debug2: Network child is on pid 2331
debug1: permanently_set_uid: 998/998 [preauth]
debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug2: local server KEXINIT proposal [preauth]
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-]
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256 [preauth]
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth]
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com [preauth]
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h]
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,h]
debug2: compression ctos: none,zlib@openssh.com [preauth]
debug2: compression stoc: none,zlib@openssh.com [preauth]
debug2: languages ctos:  [preauth]
debug2: languages stoc:  [preauth]
debug2: first_kex_follows 0  [preauth]
debug2: reserved 0  [preauth]
debug2: peer client KEXINIT proposal [preauth]
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-]
debug2: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.co]
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc [preauth]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc@lysator.liu.se,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc [preauth]
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth]
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com [preauth]
debug2: compression ctos: none [preauth]
debug2: compression stoc: none [preauth]
debug2: languages ctos:  [preauth]
debug2: languages stoc:  [preauth]
debug2: first_kex_follows 0  [preauth]
debug2: reserved 0  [preauth]
debug1: kex: algorithm: curve25519-sha256 [preauth]
debug1: kex: host key algorithm: rsa-sha2-512 [preauth]
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none [preauth]
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: SSH2_MSG_KEX_ECDH_INIT received [preauth]
debug2: monitor_read: 6 used once, disabling now
debug2: set_newkeys: mode 1 [preauth]
debug1: rekey out after 4294967296 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug2: set_newkeys: mode 0 [preauth]
debug1: rekey in after 4294967296 blocks [preauth]
debug1: KEX done [preauth]
Fingerprint: 86 AD B2 21 33 60 65 3D 9A 29 86 DE 22 99 DA 18 CC BA D3 AC 
debug1: userauth-request for user root service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug2: parse_server_config_depth: config reprocess config len 1
debug2: monitor_read: 8 used once, disabling now
debug2: input_userauth_request: setting up authctxt for root [preauth]
debug2: input_userauth_request: try method none [preauth]
debug2: monitor_read: 4 used once, disabling now
Authentication methods: publickey,password,keyboard-interactive
debug1: userauth-request for user root service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug2: input_userauth_request: try method publickey [preauth]
debug2: userauth_pubkey: valid user root querying public key ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxIgBuZS39D4bFnWminE7svGQLdVKx1aWKnEYEa+XtNU4DKZ/pxUHg0zbEBya+IkX1yqQYWALoiOwI8XhdemLp8g03BX7o+DLSWisfiHpCDVGAuNqR]
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
debug2: userauth_pubkey: authenticated 0 pkalg ssh-rsa [preauth]
	Authentication by public key failed!
Received disconnect from 127.0.0.1 port 59872:11: Normal Shutdown [preauth]
Disconnected from authenticating user root 127.0.0.1 port 59872 [preauth]
debug1: do_cleanup [preauth]
debug1: monitor_read_log: child log fd closed
debug1: do_cleanup
debug1: Killing privsep child 2331

@willco007
Copy link
Member

To fix this in the short term you can re-enable ssh-rsa by adding PubkeyAcceptedAlgorithms =+ rsa-sha to the sshd config file. I'm looking at what it takes to upgrade the RSA key to use a stronger algorithm since sha1 is now disabled by default.

@icebluey
Copy link
Author

It's time to support ssh-ed25519 and ecdsa-sha2-nistp521 in host key algorithms right now.

@willco007
Copy link
Member

@icebluey libssh2 supports both of them, the tests are just set up to use RSA keys. Which, in this case, is exposed a breaking change with OpenSSH 8.8 which libssh2 will need to support. See #536 which is ultimately why it's breaking.

@icebluey
Copy link
Author

Is it possible to add ssh-ed25519 and ecdsa-sha2-nistp521 to the tests?
Then if RSA fails, one of these can pass.

@willco007
Copy link
Member

Rebuilding from the latest changes in #626 should resolve this issue.

@Zenju
Copy link
Contributor

Zenju commented Feb 7, 2022

Rebuilding from the latest changes in #626 should resolve this issue.

For what it's worth, the latest official release libssh 1.10.0 is broken for OpenSSH_8.8p1 servers and newer (e.g. on openSUSE Tumbleweed) when trying to log in via key file (libssh2_userauth_publickey_frommemory), instead of user/password.
However these changes seem to fix the issue when testing today's master branch!

@willco007
Copy link
Member

@Zenju Thanks for the confirmation! I'm going to close this as fixed with #626.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants