Paramiko authentication fails with “Agreed upon ‘rsa-sha2-512’ pubkey algorithm” (and “unsupported public key algorithm: rsa-sha2-512” in sshd log)

Imo, it’s a bug in Paramiko. It does not handle correctly absence of server-sig-algs extension on the server side.

Try disabling rsa-sha2-* on Paramiko side altogether:

ssh_client.connect(
  server, username=ssh_user, key_filename=ssh_keypath,
  disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"]))

(note that there’s no need to specify port=22, as that’s the default)

I’ve found related Paramiko issue:
RSA key auth failing from paramiko 2.9.x client to dropbear server

Though it refers to Paramiko 2.9.0 change log, which seems to imply that the behavior is deliberate:

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.


Since 2.9.2, Paramiko will say:

DEB [20220113-14:46:13.882] thr=1 paramiko.transport: Server did not send a server-sig-algs list; defaulting to our first preferred algo (‘rsa-sha2-512’)
DEB [20220113-14:46:13.882] thr=1 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!


Obligatory warning: Do not use AutoAddPolicy – You are losing a protection against MITM attacks by doing so. For a correct solution, see Paramiko “Unknown Server”.


Your code for waiting for command to complete and reading its output is flawed too. See Wait to finish command executed with Python Paramiko. And for most purposes, the get_pty=True is not a good idea either.

Leave a Comment