SSH "server gave bad signature for RSA key 0" (client_global_hostkeys_private_confirm)
server gave bad signature for RSA key 0 is a harmless UpdateHostKeys warning from an old server. Your login worked; UpdateHostKeys no for that host hides it.
client_global_hostkeys_private_confirm: server gave bad signature for RSA key 0
Newer OpenSSH clients print the same thing as client_global_hostkeys_prove_confirm: server gave bad signature for RSA key 0, sometimes with a reason after it, such as : error in libcrypto.
This line is not why a login, git pull or scp failed. It appears after the server has already been verified and you have already logged in, and the session carries on. It only means the client gave up on one optional step: saving extra host keys to known_hosts. If your command still fails, the cause is in the other lines of output.
What the client was doing
OpenSSH 8.5 and later turn on UpdateHostKeys by default, subject to some conditions. After login, an OpenSSH server lists all of its host keys. For each key the client has not saved yet, the client asks the server to prove it holds the matching private key by signing some data with it. If a proof checks out, the client adds the key to known_hosts. See Rotate an SSH host key without warnings: UpdateHostKeys for the whole mechanism.
"RSA key 0" means the first key in the server's list, which is an RSA key. "Bad signature" means the proof for it did not verify, so the client skips the update and nothing in known_hosts changes.
Why the proof fails
RSA keys can sign with SHA-1 (ssh-rsa) or with SHA-2 (rsa-sha2-256, rsa-sha2-512). OpenSSH servers before 7.7 sign these proofs with the key's default, ssh-rsa, which uses SHA-1. A newer client can refuse that signature in two ways:
- It expects the connection's RSA type. When the connection itself was verified with an RSA host key using
rsa-sha2-256orrsa-sha2-512, the client checks RSA proofs with that same type, so a SHA-1 proof fails. - SHA-1 signatures are turned off on the client system. RHEL 9's default system-wide crypto policy does not allow SHA-1 in signatures. Red Hat documents this warning, ending in
error in libcrypto, for a RHEL 9 client logging in to a RHEL 7 server.
Either way the server's key is fine; only the signature type of the proof is the problem.
Make it stop
Turn the update off for that host
In ~/.ssh/config:
Host host.example.com
UpdateHostKeys no
To test first, run ssh -o UpdateHostKeys=no [email protected]. The only thing you lose is automatic learning of new host keys for that host.
Save the server's other keys yourself
The client only asks for proofs of keys it has not saved. Once known_hosts already has every key the server offers, no proof is requested and the warning stops. Fetch the keys with ssh-keyscan host.example.com > keys.txt, list their fingerprints with ssh-keygen -lf keys.txt, compare each one with a fingerprint the administrator gives you, then add the lines to ~/.ssh/known_hosts. Do not skip the fingerprint check; ssh-keyscan does not verify anything. See Known hosts and fingerprints.
Upgrade the server
If you run the host, OpenSSH 7.7 or later signs the proof with the type the connection negotiated.
Do not turn SHA-1 signatures back on system-wide (for example the DEFAULT:SHA1 or LEGACY crypto policy on RHEL 9) just to silence this line. It affects every program on the system, and this warning does not block anything.
Messages that look similar
REMOTE HOST IDENTIFICATION HAS CHANGEDmeans the key the server presented does not match the saved one, and the client stops. See Read the SSH warning "REMOTE HOST IDENTIFICATION HAS CHANGED".Load key "...": error in libcryptois about a private key file on your side, not the server. See SSH Load key "invalid format" and "error in libcrypto".no matching host key type found. Their offer: ssh-rsameans the client will not accept the old SHA-1 RSA signature at all, so no connection is made. See SSH "no matching key exchange method" and "no matching host key type" errors.
Related
- Rotate an SSH host key without warnings: UpdateHostKeys
- Known hosts and fingerprints
- Read the SSH warning "REMOTE HOST IDENTIFICATION HAS CHANGED"
- SSH "no matching key exchange method" and "no matching host key type" errors
- SSH error messages, what each one means
Sources
- ssh_config(5) manual: UpdateHostKeys
- OpenSSH 8.5 release notes: UpdateHostKeys on by default
- OpenSSH portable source, clientloop.c: checking the host key proofs
- OpenSSH portable 7.7 source, serverloop.c: proofs signed with the negotiated type
- OpenSSH PROTOCOL, section 2.5: hostkeys-00 and hostkeys-prove-00
- ssh-keyscan(1) manual
- Red Hat: using system-wide cryptographic policies in RHEL 9 (SHA-1 in signatures)
- Red Hat Customer Portal: bad signature for RSA key 0 from RHEL 9 to RHEL 7