SSH "sign_and_send_pubkey: no mutual signature supported"
sign_and_send_pubkey: no mutual signature supported means an old SSH server only checks SHA-1 ssh-rsa signatures. Use Ed25519 or allow ssh-rsa for that host.
sign_and_send_pubkey: no mutual signature supported
[email protected]: Permission denied (publickey).
The key file loaded fine. The problem is the signature: to log in with a key, the client signs a challenge, and both sides must accept the same signature algorithm. Here they share none, so the client gives up on that key and moves on. With ssh -v the same thing shows as send_pubkey_test: no mutual signature algorithm.
Why it happens with RSA keys
An RSA key can sign in three ways:
ssh-rsa, with the SHA-1 hash, the original methodrsa-sha2-256andrsa-sha2-512, with SHA-2 (RFC 8332)
A server tells the client which of these it accepts with the server-sig-algs extension (RFC 8308). OpenSSH servers have supported the SHA-2 methods since version 7.2.
An older server, or a device with an old SSH library, sends no such list. The client can then only use ssh-rsa. OpenSSH 8.8 (2021) removed ssh-rsa from the client's default PubkeyAcceptedAlgorithms because SHA-1 is broken, so a current client has nothing left to offer for that key.
The key itself is fine. The same RSA key still works on any server that speaks SHA-2.
Confirm it
ssh -v [email protected]
Look for the line with remote software version. A version of OpenSSH older than 7.2, or an unfamiliar embedded SSH server, points to this cause. Then try once with SHA-1 allowed:
ssh -o PubkeyAcceptedAlgorithms=+ssh-rsa [email protected]
If that logs in, you have found the cause.
Fixes, best first
- Use an Ed25519 key on that server. Ed25519 has its own signature method with no SHA-1 variant. OpenSSH servers accept it from version 6.5. ECDSA keys also avoid the problem.
- Upgrade the server's SSH software, if you control it. From OpenSSH 7.2 it signs and verifies with SHA-2 on its own.
- Allow
ssh-rsafor that one host only. OpenSSH calls this a stopgap. In~/.ssh/config:
Host old-host
HostName 192.0.2.10
PubkeyAcceptedAlgorithms +ssh-rsa
The + adds ssh-rsa to the default list instead of replacing it. Do not put this under Host *. Clients older than OpenSSH 8.5 call the option PubkeyAcceptedKeyTypes.
If the same server also has only an RSA host key, the connection stops earlier with no matching host key type found. That needs HostKeyAlgorithms +ssh-rsa as well: see SSH "no matching key exchange method" and "no matching host key type" errors.
Other keys
The same message appears for any key whose type is not in the client's PubkeyAcceptedAlgorithms, for example an old DSA (ssh-dss) key, which OpenSSH has refused by default since version 7.0. Replace such a key with Ed25519.
The reverse case
A current server can refuse an old client that offers only ssh-rsa. The client then shows only Permission denied (publickey), and the reason is in the server's log. The fix is the same: a newer client, or an Ed25519 key.
Related
- SSH "no matching key exchange method" and "no matching host key type" errors
- Key types and formats
- SSH Load key "invalid format" and "error in libcrypto"
- SSH error messages, what each one means
- PuTTY "Server refused our key": why and how to fix it
Sources
- OpenSSH 8.8 release notes: RSA SHA-1 signatures disabled by default
- OpenSSH 7.2 release notes: RSA SHA-256/512 signatures
- OpenSSH 6.5 release notes: Ed25519 keys
- OpenSSH 8.5 release notes: PubkeyAcceptedKeyTypes renamed
- ssh_config(5): PubkeyAcceptedAlgorithms
- OpenSSH sshconnect2.c: choosing the signature algorithm
- RFC 8332: RSA keys with SHA-256 and SHA-512
- RFC 8308: extension negotiation and server-sig-algs
- OpenSSH legacy options