You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RSA key auth failing from paramiko 2.9.x client to dropbear server #1961
This was found in the OpenStack CI which uses Cirros as a small cloud image for testing purposes. Cirros runs dropbear as ssh server. There a no issues connecting with paramiko < 2.9, with the latest versions, authentication with an RSA key is failing, while using an ECDSA key or password login still works. The failure looks like this, sadly I haven't found out yet how to gather more debugging about the connection process:
Traceback (most recent call last):
File "test.py", line 12, in <module>
client.connect(host, username=user)
File "/home/ubuntu/vv/lib/python3.8/site-packages/paramiko/client.py", line 435, in connect
self._auth(
File "/home/ubuntu/vv/lib/python3.8/site-packages/paramiko/client.py", line 766, in _auth
raise saved_exception
File "/home/ubuntu/vv/lib/python3.8/site-packages/paramiko/client.py", line 742, in _auth
self._transport.auth_publickey(username, key)
File "/home/ubuntu/vv/lib/python3.8/site-packages/paramiko/transport.py", line 1634, in auth_publickey
return self.auth_handler.wait_for_response(my_event)
File "/home/ubuntu/vv/lib/python3.8/site-packages/paramiko/auth_handler.py", line 263, in wait_for_response
raise e
paramiko.ssh_exception.AuthenticationException: Authentication failed.
We have the same issue..
RSA stopped working for paramiko > 2.8.1 (both 2.9.0 and 2.9.1 was tested) while other algorithms works ok.
We are connecting to debian open ssh servers.
After seeing the demo code, I found that using util.log_to_file() gives me the debug output I was looking for. It seems that the server fails to announce any viable algorithm:
DEB [20211229-11:24:51.106] thr=1 paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
DEB [20211229-11:24:51.106] thr=1 paramiko.transport: Server-side algorithm list: ['']
DEB [20211229-11:24:51.106] thr=1 paramiko.transport: Agreed upon 'rsa-sha2-512' pubkey algorithm
INF [20211229-11:24:51.180] thr=1 paramiko.transport: Authentication (publickey) failed.
Doing some more testing, disabled_keys = {'pubkeys':['rsa-sha2-512','rsa-sha2-256']} does work around the issue, but I wonder if the default behavior could/should be more backwards compatible at least until a major version step is done, like by falling back to ssh-rsa if the server provides an empty list.
When the server does not send server-sig-algs, Paramiko will attempt the first algorithm in the above list. Clients connecting to legacy servers should thus use disabled_algorithms to turn off SHA2.
Currently, it is need to use disabled_algorithms to connect to old ssh server.
so it looks like paramiko is failing to handle this properly. The dropbear version currently being used in cirros is 2018.76, it will certainly make sense towards an update on that end, too.
Same issue here using fabric with a proxy jump.
Connection was granted to the relay host (Ubuntu) but failed on the destination (Debian 9.11) with the same error log and an empty Server-side algorithm list.
Workaround is to set transport.server_extensions = {'server-sig-algs': 'ssh-rsa'} after initiating Transport().
t=paramiko.Transport(sock)
# workaround for #1961ifhasattr(t, 'server_extensions'):
t.server_extensions= {'server-sig-algs': 'ssh-rsa'}
t.start_client()
I consider that the following patch will fix the issue without use of disabled_algorithms by the user.
diff --git a/paramiko/transport.py b/paramiko/transport.py
index b99b3278d..141192eeb 100644
--- a/paramiko/transport.py+++ b/paramiko/transport.py@@ -679,6 +679,9 @@ class Transport(threading.Thread, ClosingContextManager):
`.SSHException` -- if negotiation fails (and no ``event`` was
passed in)
"""
+ # backwards-compatibility for old ssh servers which doesn't send+ # server-sig-algs in MSG_EXT_INFO.+ self.server_extensions = {"server-sig-algs": "ssh-rsa"}
self.active = True
if event is not None:
# async, return immediately and let the app poll for completion
Reacted by Pierce Lopez, Wenbo Zhao, Zach Liu, Babak, VictorPiovesan, Jonel G and Alan Li
I believe the problem is that Paramiko does not handle correctly an absence of server-sig-algs extension on the server side. Instead of disabling rsa-sha2-512 and rsa-sha2-256, it actually forces use of the rsa-sha2-512.
2.9.2 now out with the above. I'm going to close this as "WONTFIX". If anyone can identify legit issues with the new feature that are not fixable by using disabled_algorithms (or pinning to 2.8.x until one's servers are upgraded - absolutely an acceptable solution!), please file a new ticket with details and proof - thanks!
A system has devices running both newer and older versions of dropbear.
SSH connections via paramiko to newer versions of dropbear will work.
SSH connections via paramiko to older versions of dropbear will not work.
We can apply the fix disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"]),, but wouldn't that mean that on new version of dropbear we'd be using the old sha1?
I think a good solution could be to change this code as follows:
And allow us to pass a list of preferred_rsa_keys which is backward compatible with old systems.
Sometimes old routers cannot be upgraded because they're EOL, but customers may want to keep using them in their internal network which they consider secure for internal usage by their employees. It wouldn't be great to force them to throw those away just because of this, sooner or later these routers will die anyway but it's better to have an easier way to maintain backward compatibility and support them.
@nemesisdesign This seems like a sensible feature request to consider. Can you repost as a new issue on the repo, with a link back to your comment here? Thanks!
For any one coming here, now a couple of extra steps need to be made:
Monkey patch the transport to re-add the now disappeared ssh-rsa algorithm. For this, now we are forcecd to use the Transport instead of the SSHClient.
Re-enable legacy ssh-rsa (SHA-1) signing.
importparamikoimportsocketfromcryptography.hazmat.primitivesimporthashesascrypto_hashes# Re-enable legacy ssh-rsa (SHA-1) signingparamiko.RSAKey.HASHES['ssh-rsa'] =crypto_hashes.SHA1# Read the keykey=paramiko.RSAKey.from_private_key_file(keyfile)
# Manually start the transportsock=socket.create_connection((ip, port), timeout=50)
transport=paramiko.Transport(sock)
# Monkey patch the transport to re-add the now disappeared `ssh-rsa` algorithmtransport._preferred_pubkeys= ('ssh-rsa',)
# Start the connectiontransport.connect(username=username, pkey=key)
# Wrap the tgransport with the clientclient=paramiko.SSHClient()
client._transport=transport
Activity
ingwarsw commentedon Dec 29, 2021
We have the same issue..
RSA stopped working for paramiko > 2.8.1 (both 2.9.0 and 2.9.1 was tested) while other algorithms works ok.
We are connecting to debian open ssh servers.
Will try to get more debugging logs.
osfrickler commentedon Dec 29, 2021
After seeing the demo code, I found that using
util.log_to_file()gives me the debug output I was looking for. It seems that the server fails to announce any viable algorithm:Doing some more testing,
disabled_keys = {'pubkeys':['rsa-sha2-512','rsa-sha2-256']}does work around the issue, but I wonder if the default behavior could/should be more backwards compatible at least until a major version step is done, like by falling back to ssh-rsa if the server provides an empty list.yoctozepto commentedon Dec 29, 2021
Does the server actually fail to announce the algorithm list or paramiko fails to parse it?
marcelorik commentedon Dec 29, 2021
same issue here, working in version 2.8.1
jun66j5 commentedon Dec 29, 2021
According to https://matt.ucc.asn.au/dropbear/CHANGES, Dropbear 2020.79 supports rsa-sha2 signatures. Are you using what version of dropbear?
Also, changelog of paramiko says:
Currently, it is need to use disabled_algorithms to connect to old ssh server.
ingwarsw commentedon Dec 29, 2021
As you can see from log its Debian OpenSSH not Dropbear.
The same issue..
Server-side algorithm list: ['']looks bad ..osfrickler commentedon Dec 29, 2021
When I connect with
ssh -vvthe server sendsso it looks like paramiko is failing to handle this properly. The dropbear version currently being used in cirros is 2018.76, it will certainly make sense towards an update on that end, too.
SGRelic commentedon Dec 29, 2021
Same issue here using fabric with a proxy jump.
Connection was granted to the relay host (Ubuntu) but failed on the destination (Debian 9.11) with the same error log and an empty Server-side algorithm list.
jun66j5 commentedon Dec 31, 2021
Workaround is to set
transport.server_extensions = {'server-sig-algs': 'ssh-rsa'}after initiatingTransport().I consider that the following patch will fix the issue without use of disabled_algorithms by the user.
martinprikryl commentedon Jan 3, 2022
I believe the problem is that Paramiko does not handle correctly an absence of
server-sig-algsextension on the server side. Instead of disablingrsa-sha2-512andrsa-sha2-256, it actually forces use of thersa-sha2-512.See https://stackoverflow.com/q/70565357/850848
teunis90 commentedon Jan 5, 2022
I can confirm that I still hit the same/similar bug on version 2.9.1 using RSA keys. If we switch to password login it does work.
Here's the debug trace:
Fails:
Works:
Also tried with settings:
Which does change the Key exchange agreements, but I still get the same error:
Code in
test-ssh.py:Cisco device does not support
ssh-dss, and password login is prohibited on production. Can I add anymore information to support resolving this issue?martinprikryl commentedon Jan 5, 2022
@teunis90 My answer as Stack Overflow question linked in my previous comment shows how to workaround the issue.
teunis90 commentedon Jan 5, 2022
Thanks @martinprikryl this fixed my issue!
Disallow paramiko 2.9.0 and 2.9.1
Disallow paramiko 2.9.0 and 2.9.1
6 remaining items
bitprophet commentedon Jan 8, 2022
2.9.2 now out with the above. I'm going to close this as "WONTFIX". If anyone can identify legit issues with the new feature that are not fixable by using
disabled_algorithms(or pinning to 2.8.x until one's servers are upgraded - absolutely an acceptable solution!), please file a new ticket with details and proof - thanks!Disable unsupported SHA-2 pubkey algorithms
Disable unsupported SHA-2 pubkey algorithms (#67)
nemesifier commentedon May 3, 2022
What about the following situation?
A system has devices running both newer and older versions of dropbear.
SSH connections via paramiko to newer versions of dropbear will work.
SSH connections via paramiko to older versions of dropbear will not work.
We can apply the fix
disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"]),, but wouldn't that mean that on new version of dropbear we'd be using the old sha1?I think a good solution could be to change this code as follows:
paramiko/paramiko/transport.py
Lines 1338 to 1343 in f2b4be8
And allow us to pass a list of
preferred_rsa_keyswhich is backward compatible with old systems.Sometimes old routers cannot be upgraded because they're EOL, but customers may want to keep using them in their internal network which they consider secure for internal usage by their employees. It wouldn't be great to force them to throw those away just because of this, sooner or later these routers will die anyway but it's better to have an easier way to maintain backward compatibility and support them.
bskinn commentedon May 6, 2022
@nemesisdesign This seems like a sensible feature request to consider. Can you repost as a new issue on the repo, with a link back to your comment here? Thanks!
Update connection.py
nemesifier commentedon May 11, 2022
Thanks for the feedback @bskinn, I opened #2049.
Bump paramiko version
mirceaulinic commentedon Jul 26, 2022
Is anyone aware if there's an option I could throw into the SSH config file instead of applying a patch?
alexNMD commentedon Mar 4, 2023
You can also, in order to avoid edge effect disable algorithms for all connections use that :
Changelog entry for signature algorithm fallback change re #2012, re #…
Commit #1
emibcn commentedon Jun 22, 2026
For any one coming here, now a couple of extra steps need to be made:
ssh-rsaalgorithm. For this, now we are forcecd to use the Transport instead of theSSHClient.Disable unsupported SHA-2 pubkey algorithms (Evidlo#67)