Open belkir opened 4 years ago
Would need a libssh2 trace to say what the issue is. Would think the server is using a configuration libssh2 does not support.
Would need a libssh2 trace to say what the issue is. Would think the server is using a configuration libssh2 does not support.
Ok, how I can trace libssh2 connection?
Additional info: debug from Cisco Router:
Nov 17 06:38:21.592: SSH3: starting SSH control process
Nov 17 06:38:21.592: SSH3: sent protocol version id SSH-2.0-Cisco-1.25
Nov 17 06:38:21.636: SSH3: protocol version id is - SSH-2.0-libssh2_1.9.0_DEV
Nov 17 06:38:21.640: SSH2 3: SSH2_MSG_KEXINIT sent
Nov 17 06:38:21.640: SSH2 3: SSH2_MSG_KEXINIT received
Nov 17 06:38:21.640: SSH2:kex: client->server enc:aes256-cbc mac:hmac-sha1
Nov 17 06:38:21.640: SSH2:kex: server->client enc:aes256-cbc mac:hmac-sha1
Nov 17 06:38:21.680: SSH2 3: SSH2_MSG_KEX_DH_GEX_REQUEST received
Nov 17 06:38:21.680: SSH2 3: Range sent by client is - 1024 < 1536 < 2048
Nov 17 06:38:21.680: SSH2 3: Invalid modulus length
Nov 17 06:38:21.780: SSH3: Session disconnected - error 0x00
Tracing functionality is not merged into master yet, will show code to enable libssh2 tracing then. It will also need to be compiled into libssh2.
Looking at debug above, looks like method_pref
would need to be used to select a different key exchange method. Method pref functions are now implemented - #128
The Openssh client is also using different client key type, might not be related.
If this is an old cisco router is too possible that KexAlghoritms were different to the system default.
take into consideration the next trace:
Nov 17 06:38:21.680: SSH2 3: SSH2_MSG_KEX_DH_GEX_REQUEST received Nov 17 06:38:21.680: SSH2 3: Range sent by client is - 1024 < 1536 < 2048 Nov 17 06:38:21.680: SSH2 3: Invalid modulus length
I have the same error, connecting to an CentOS8 stream system. Normal ssh connection will work. SSH config of my target:
PORT STATE SERVICE 22/tcp open ssh | ssh2-enum-algos: | kex_algorithms: (1) | curve25519-sha256@libssh.org | server_host_key_algorithms: (4) | ssh-rsa | rsa-sha2-512 | rsa-sha2-256 | ssh-ed25519 | encryption_algorithms: (2) | chacha20-poly1305@openssh.com | aes256-gcm@openssh.com | mac_algorithms: (2) | hmac-sha2-512-etm@openssh.com | hmac-sha2-256-etm@openssh.com | compressionalgorithms: (2) | none | zlib@openssh.com
libssh2: libssh2-1.9.0-7.fc34.x86_64
server log: no matching cipher found. Their offer: 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,none [preauth]
It looks like libssh2 don't support modern ciphers.
Thanks for the feedback.
There is a new version of libssh2 available, will re-test once ssh2-python has been updated.
The above does not appear to be the same issue though.
In the meantime, I have switched to ssh-python, which will use libssh instant of libssh2. Here the new ciphers will work.
Use the high level clients in parallel-ssh instead of either ssh-python or ssh2-python directly. Unless you are feeling particularly masochistic.
if an openssh system, sshd_config can support libssh2 with PubkeyAcceptedKeyTypes
and/or HostKeyAlgorithms
options filled in. check the manual page first man sshd_config
and see re: ssh -Q cipher
Bug reports
Steps to reproduce:
Example code that produces error: Python 3.8.3 (default, Jun 18 2020, 20:51:40) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information.
ssh -vvv 10.10.11.121
Additional info: [
libssh2
version 0.23.0, RHEL7]Hi! Getting a KeyExchangeError while connecting to old Cisco router. Any ideas how to fix that?