Re-enable a legacy SSH key exchange or ssh-rsa for one host, not every connection
Held against openssh 10.5p1-1 on omarchy 4.0.2-1 by reading only: man 5 ssh_config on this machine, ssh -Q kex, key, sig, HostKeyAlgorithms and PubkeyAcceptedAlgorithms, ssh -G against a placeholder host, and the OpenSSH 7.0, 8.2, 8.5, 8.8 and 10.0 release notes plus the pinned packet.c, ssherr.c, readconf.c and sshconnect2.c. The fix holds: the + append syntax, the option names HostKeyAlgorithms, PubkeyAcceptedAlgorithms and KexAlgorithms, and first-value-wins ordering are all in the installed manual, the Host old-host stanza is the 8.8 release notes' own example, and readconf.c dump_client_config expands HostKeyAlgorithms so the verify's ssh -G check shows the appended algorithm. PubkeyAcceptedAlgorithms is the right name: renamed from PubkeyAcceptedKeyTypes in 8.5, the old name is still read as an obsolete alias in readconf.c and the manual on this machine documents only the new one. Wrong: the cause says none of the algorithms were deleted from what the binary can do, but release 10.0 removed DSA entirely and ssh -Q key on 10.5p1-1 lists no ssh-dss, so a server offering only DSA host keys cannot be reached by any configuration. Wrong: ssh -Q key lists key types, not signature algorithms, so it is the wrong list to cite for ssh-rsa, though ssh -Q HostKeyAlgorithms and ssh -Q PubkeyAcceptedAlgorithms do list it. Wrong: the quoted error omits the port, packet.c prints Unable to negotiate with <addr> port <port>: <reason>. Their offer: <list>, and the reason strings match ssherr.c. Wrong: the danger says both DH groups were removed in 'those same two releases' right after naming 8.2 and 8.8, and group1-sha1 was 7.0. Symptom, cause and danger rewritten, fix kept as is, severity lowered to medium: no default is weak, the control is the algorithm list and a scoped + line weakens one host by a SHA-1 collision that needs an on-path attacker with substantial compute, which is the brief's medium. Gate 1 passes on release notes and the manual, gate 3 passes. No overlap in problems.jsonl: no record mentions KexAlgorithms, HostKeyAlgorithms, PubkeyAccepted or either negotiate error.
A HostKeyAlgorithms, PubkeyAcceptedAlgorithms or KexAlgorithms line placed under Host *, or written without the leading + so it replaces the default list rather than extending it, weakens every SSH connection the machine makes, not only the one that needed it. ssh-rsa signs with SHA-1, which OpenSSH's own release 8.2 and 8.8 notes say can be forged with a chosen-prefix collision for under USD 50,000, and that is the stated reason OpenSSH stopped offering it by default. diffie-hellman-group1-sha1 was removed from the default key exchange proposal in release 7.0 and diffie-hellman-group14-sha1 in release 8.2, and both hash with the same SHA-1. A replacing HostKeyAlgorithms list has a second cost: the client stops preferring the key types it already holds in known_hosts for a host, which is one way to earn the changed-host-key warning covered by ssh-host-key-warning-after-algorithm-order-change. A + line keeps that preference.
Symptom
ssh refuses a server it used to reach, with Unable to negotiate with <host> port 22: no matching key exchange method found or Unable to negotiate with <host> port 22: no matching host key type found, each followed by Their offer: and the list the server proposed, right after an OpenSSH update. The advice that turns up online is to drop a PubkeyAcceptedAlgorithms, HostKeyAlgorithms or KexAlgorithms line into /etc/ssh/ssh_config so it stops happening again.
Cause
OpenSSH has turned off or removed several algorithms across a series of releases, each documented in that release's own notes: release 7.0 (2015) disabled the 1024-bit diffie-hellman-group1-sha1 key exchange and ssh-dss keys by default, release 8.2 (2020) removed diffie-hellman-group14-sha1 from the default key exchange proposal and dropped ssh-rsa from the accepted certificate signature algorithms, and release 8.8 (2021) disabled the SHA-1 ssh-rsa signature for host and user authentication by default. Release 10.0 (2025) then removed DSA entirely. On this machine, openssh 10.5p1-1, ssh -Q kex still lists diffie-hellman-group1-sha1 and diffie-hellman-group14-sha1, and ssh -Q HostKeyAlgorithms and ssh -Q PubkeyAcceptedAlgorithms still list ssh-rsa, so those three are only left out of what the client offers by default and can be added back. ssh -Q key lists no ssh-dss at all, so a server that offers only DSA host keys cannot be reached from this client by any configuration. A server that has not been reconfigured or upgraded since one of those releases, common on older network gear and appliances, ends up with no algorithm in common with a current client, and the client says so, naming what the server proposed: Unable to negotiate with <host> port <port>: <reason>. Their offer: <list>. PubkeyAcceptedAlgorithms is the current name of the option, renamed from PubkeyAcceptedKeyTypes in release 8.5. The old name is still read as an alias on 10.5p1, but the manual on this machine documents only the new one.
Fix
Re-enable the one algorithm the old server needs, for that one server, in ~/.ssh/config, using the + syntax OpenSSH documents for exactly this purpose: appending to the default set rather than replacing it. This is the same shape OpenSSH's own release 8.8 notes give as the recommended stopgap:
# ~/.ssh/config
Host old-host
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
For a key exchange failure, append the specific algorithm the server offered instead, read from the client's own error message rather than guessed:
# ~/.ssh/config
Host old-host
KexAlgorithms +diffie-hellman-group14-sha1
Put this under a Host block naming the one server, placed before any wider Host * block. man 5 ssh_config says the file is read in order and the first value given for a directive wins, so a narrow block has to come first to take effect. Never write a +-less, replacing HostKeyAlgorithms, PubkeyAcceptedAlgorithms or KexAlgorithms line, and never place any of the three under Host * or directly in /etc/ssh/ssh_config with no Host restriction. Either mistake re-enables the weak algorithm for every host the machine ever connects to, not only the one that still needs it. Treat the re-enabled line as temporary: OpenSSH's own notes recommend it only until the remote side can be upgraded or reconfigured with a current key type.
Verify
ssh -G old-host | grep -i 'hostkeyalgorithms\|kexalgorithms\|pubkeyacceptedalgorithms' lists the legacy algorithm in the output for that one host, and the same command run against an unrelated host on the same machine does not list it, confirming the change stayed inside the Host old-host block instead of reaching Host *.
Sources
- https://man.openbsd.org/ssh_config.5
- https://www.openssh.com/txt/release-7.0
- https://www.openssh.com/txt/release-8.2
- https://www.openssh.com/txt/release-8.8
- https://github.com/openssh/openssh-portable/blob/bc41d062cc0f305e49d58430b467c3ce8c822a87/packet.c
- https://www.openssh.com/txt/release-8.5
- https://www.openssh.com/txt/release-10.0
- https://github.com/openssh/openssh-portable/blob/bc41d062cc0f305e49d58430b467c3ce8c822a87/ssherr.c
- https://github.com/openssh/openssh-portable/blob/bc41d062cc0f305e49d58430b467c3ce8c822a87/readconf.c
- https://github.com/openssh/openssh-portable/blob/bc41d062cc0f305e49d58430b467c3ce8c822a87/sshconnect2.c