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
Paramiko 2.9.0 breaks compatibility with devices only supporting ssh-rsa and not supporting server-sig-algs #2012
This issue is observed when using napalm and a Cisco ASR9001 running IOS-XR 6.7.3.
When trying to connect to such a device, paramiko only tries ssh-rsa512, fails and then gives up.
I would expect it to try the other algorithms in its list until it finds one that is working.
I am aware of the possibility to set disabled_algorithm but to my knowledge, napalm does not support setting this option.
This however is an issue that I will report to the napalm team.
Nonetheless, I think the behaviour of paramiko should be changed to regain compatibility with these legacy SSH daemons.
Is there any update on this? The latest Ubuntu release (jammy, 22.04) includes version 2.9.3, so I think a lot of people are going to encounter this problem in the near future...and setting disabled_algorithm doesn't seem very user-friendly or, in some cases, even possible, if paramiko is used internally with some bigger python app.
A rewrite of the key authentication logic is on @bitprophet's roadmap, which IIUC would make all of the disabled_algorithms awkwardness unnecessary. (I know he very much dislikes the whole disabled_algorithms two-step, but it was the least-worst quick fix for some recent problems.)
Unfortunately, AFAIK there's no specific timeline for this rewrite (other things are higher priority; plus, @bitprophet has to balance paramiko with invoke and fabric in his OSS time), so downstream projects may just need to figure out how to cope with the disabled_algorithms interface for now. :-/
This was handled in #2017 but figured I'd add my below findings after @bitprophet 's bugfix. Didn't want to create a new issue since this one was still open.
Issue persists on OpenSSH 5.3. This is the latest version available for CentOS/CloudLinux 6 servers. This openssh version only offers "ssh-rsa" and the code that was implemented is explicitly looking for the "[email protected]" key type.
paramiko debug:
DEBUG:paramiko.transport:Finalizing pubkey algorithm for key of type 'ssh-rsa'
DEBUG:paramiko.transport:Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
DEBUG:paramiko.transport:Server did not send a server-sig-algs list; defaulting to our first preferred algo ('rsa-sha2-512')
DEBUG:paramiko.transport:NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!
INFO:paramiko.transport:Authentication (publickey) failed.
sshd log:
sshd[177383]: userauth_pubkey: unsupported public key algorithm: rsa-sha2-512
It sounds like the specific problem named by OP in this issue is fixed by #2017, but your comment notes a new/different problem? (Or, a similar problem with a different server configuration/SSH daemon?)
If so, please repost your comment as a new issue and we'll close this one. Best to keep the scope of these issues granular and separated, since the fixes are different.
With OpenSSH_5.3 it doesn't work with 512 / 256 so if you try to disable them the preferred becomes ssh-rsa.
DEB [20221107-09:51:10.980] thr=5 paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_5.3
INF [20221107-09:51:10.982] thr=5 paramiko.transport: Connected (version 2.0, client OpenSSH_5.3)
DEB [20221107-09:51:10.984] thr=5 paramiko.transport: === Key exchange possibilities ===
DEB [20221107-09:51:10.986] thr=5 paramiko.transport: kex algos: diffie-hellman-group-exchange-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
DEB [20221107-09:51:10.987] thr=5 paramiko.transport: server key: ssh-rsa, ssh-dss
DEB [20221107-09:51:11.141] thr=5 paramiko.transport: Our pubkey algorithm list: ['rsa-sha2-512', 'rsa-sha2-256', 'ssh-rsa']
DEB [20221107-09:51:11.145] thr=5 paramiko.transport: Server did not send a server-sig-algs list; defaulting to our first preferred algo ('rsa-sha2-512')
DEB [20221107-09:51:11.146] thr=5 paramiko.transport: NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!
Unfortunately, you then might run into an issue where OpenSSH_7.4 only accepts 512/256 but we have disabled them.
So I ended up overriding paramiko.transport.Transport._preferred_pubkeys and reordering it to use ssh-rsa first.
Could the fix be to use paramiko.transport: server key (server_key_algo_list) to filter the list when server-sig-algs is not available instead of just defaulting to the [0] assuming auth_handler can access it from transport?
something like pubkey_algo = list(filter(server_key_algo_list, my_algos))[0]
# Fallback: first one in our (possibly tweaked by caller) list
pubkey_algo = my_algos[0]
msg = "Server did not send a server-sig-algs list; defaulting to our first preferred algo ({!r})" # noqa
self._log(DEBUG, msg.format(pubkey_algo))
self._log(
DEBUG,
"NOTE: you may use the 'disabled_algorithms' SSHClient/Transport init kwarg to disable that or other algorithms if your server does not support them!", # noqa
)
DEB [20221107-09:30:40.624] thr=2 paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.11.0
DEB [20221107-09:30:40.704] thr=2 paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_7.4
INF [20221107-09:30:40.705] thr=2 paramiko.transport: Connected (version 2.0, client OpenSSH_7.4)
DEB [20221107-09:30:40.777] thr=2 paramiko.transport: === Key exchange possibilities ===
...
DEB [20221107-09:30:40.901] thr=2 paramiko.transport: Switch to new keys ...
DEB [20221107-09:30:40.902] thr=2 paramiko.transport: Got EXT_INFO: {'server-sig-algs': b'rsa-sha2-256,rsa-sha2-512'}
DEB [20221107-09:30:40.902] thr=3 paramiko.transport: Attempting public-key auth...
DEB [20221107-09:30:41.084] thr=2 paramiko.transport: userauth is OK
DEB [20221107-09:30:41.086] thr=2 paramiko.transport: Finalizing pubkey algorithm for key of type 'ssh-rsa'
DEB [20221107-09:30:41.087] thr=2 paramiko.transport: Our pubkey algorithm list: ['ssh-rsa']
DEB [20221107-09:30:41.088] thr=2 paramiko.transport: Server-side algorithm list: ['rsa-sha2-256', 'rsa-sha2-512']
DEB [20221107-09:30:41.089] thr=2 paramiko.transport: No common pubkey algorithms exist! Dying.
ERR [20221107-09:30:41.089] thr=2 paramiko.transport: Exception (client): Unable to agree on a pubkey algorithm for signing a 'ssh-rsa' key!
I just ran into this problem connecting to a IOS-Xe 16.12.12 device with ssh-rsa key auth, and moved the order of pubkey algos in transport.py so ssh-rsa was before rsa-ssh2-512 and that fixed it for me. openssh on RHEL9 doesn't have a problem picking the right pubkey algo FWIW.
Activity
jun66j5 commentedon Mar 21, 2022
See #1984 (comment).
ddstreet commentedon May 12, 2022
Is there any update on this? The latest Ubuntu release (jammy, 22.04) includes version 2.9.3, so I think a lot of people are going to encounter this problem in the near future...and setting disabled_algorithm doesn't seem very user-friendly or, in some cases, even possible, if paramiko is used internally with some bigger python app.
bskinn commentedon May 13, 2022
A rewrite of the key authentication logic is on @bitprophet's roadmap, which IIUC would make all of the
disabled_algorithmsawkwardness unnecessary. (I know he very much dislikes the wholedisabled_algorithmstwo-step, but it was the least-worst quick fix for some recent problems.)Unfortunately, AFAIK there's no specific timeline for this rewrite (other things are higher priority; plus, @bitprophet has to balance paramiko with invoke and fabric in his OSS time), so downstream projects may just need to figure out how to cope with the
disabled_algorithmsinterface for now. :-/NelsonsDev commentedon May 18, 2022
This was handled in #2017 but figured I'd add my below findings after @bitprophet 's bugfix. Didn't want to create a new issue since this one was still open.
Issue persists on OpenSSH 5.3. This is the latest version available for CentOS/CloudLinux 6 servers. This openssh version only offers "ssh-rsa" and the code that was implemented is explicitly looking for the "[email protected]" key type.
paramiko debug:
sshd log:
bskinn commentedon May 26, 2022
@NelsonsDev, thanks very much for the follow-up.
It sounds like the specific problem named by OP in this issue is fixed by #2017, but your comment notes a new/different problem? (Or, a similar problem with a different server configuration/SSH daemon?)
If so, please repost your comment as a new issue and we'll close this one. Best to keep the scope of these issues granular and separated, since the fixes are different.
Downgrade paramiko
neostorm commentedon Nov 7, 2022
With OpenSSH_5.3 it doesn't work with 512 / 256 so if you try to disable them the preferred becomes ssh-rsa.
Unfortunately, you then might run into an issue where OpenSSH_7.4 only accepts 512/256 but we have disabled them.
So I ended up overriding paramiko.transport.Transport._preferred_pubkeys and reordering it to use ssh-rsa first.
Could the fix be to use paramiko.transport: server key (server_key_algo_list) to filter the list when server-sig-algs is not available instead of just defaulting to the [0] assuming auth_handler can access it from transport?
something like pubkey_algo = list(filter(server_key_algo_list, my_algos))[0]
Changelog entry for signature algorithm fallback change re #2012, re #…
mtinberg commentedon Jul 17, 2025
I just ran into this problem connecting to a IOS-Xe 16.12.12 device with ssh-rsa key auth, and moved the order of pubkey algos in transport.py so ssh-rsa was before rsa-ssh2-512 and that fixed it for me. openssh on RHEL9 doesn't have a problem picking the right pubkey algo FWIW.