SSH offers weak ciphers, MACs or key exchanges
- Check
ssh.weak_algorithms- Severity
- low
- Runs
- on the server, in the daily run of the agent
- Looks at
- CBC ciphers, MD5 or 96-bit MACs and SHA-1 key exchanges in Ciphers, MACs and KexAlgorithms
What the check looks at
The effective Ciphers, MACs and KexAlgorithms of sshd (sshd -T). The check fails when they contain a
weak algorithm: CBC-mode ciphers (aes128-cbc, 3des-cbc), arcfour, MD5-based or 96-bit MACs
(hmac-md5, hmac-sha1-96), or key exchanges with SHA-1 or small groups (diffie-hellman-group1-sha1,
diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1).
Risk
Current OpenSSH releases do not offer these algorithms by default. They come back through a Ciphers or
KexAlgorithms line added years ago for an old client, or copied from an outdated hardening guide. None of them
lets an attacker log in, so the severity is low, but they weaken the connection against someone who can record
or change the traffic, and compliance scanners flag them.
How to fix it
Find the lines:
sudo grep -rnE '^\s*(Ciphers|MACs|KexAlgorithms)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
sudo sshd -T | grep -E '^(ciphers|macs|kexalgorithms) '
Debian, Ubuntu and Alpine
Delete the lines so that the defaults apply. To drop single algorithms from the defaults, start the list
with -:
MACs -hmac-sha1*,umac-64*
The rest of the default list stays, also when a later OpenSSH release changes it. Check and reload:
sudo sshd -t
sudo systemctl reload ssh # Debian, Ubuntu
sudo rc-service sshd reload # Alpine
RHEL, Rocky Linux and AlmaLinux
The algorithms come from the system-wide crypto policy, through
/etc/crypto-policies/back-ends/opensshserver.config. On RHEL 9 and later a file in /etc/ssh/sshd_config.d/
includes it. Remove your own Ciphers, MACs and KexAlgorithms lines and set the policy:
update-crypto-policies --show
sudo update-crypto-policies --set DEFAULT
sudo systemctl restart sshd
The LEGACY policy turns old algorithms back on for the whole system; look whether someone set it.
RHEL 8, Rocky Linux 8 and AlmaLinux 8 pass the policy to sshd as command line options ($CRYPTO_POLICY in
sshd.service). They override sshd_config, and a plain sshd -T does not show them. The list the running
server uses:
sudo sh -c '. /etc/crypto-policies/back-ends/opensshserver.config; sshd -T $CRYPTO_POLICY' | grep -E '^(ciphers|macs|kexalgorithms) '
The DEFAULT policy of RHEL 8 still offers aes256-cbc, aes128-cbc, diffie-hellman-group14-sha1 and
diffie-hellman-group-exchange-sha1. The shipped NO-SHA1 module removes the two SHA-1 key exchanges, and a
small module of your own removes the CBC ciphers for SSH only:
echo 'cipher@SSH = -AES-256-CBC -AES-128-CBC' | sudo tee /etc/crypto-policies/policies/modules/NO-SSH-CBC.pmod
sudo update-crypto-policies --set DEFAULT:NO-SHA1:NO-SSH-CBC
sudo systemctl restart sshd
NO-SHA1 drops SHA-1 hashes and signatures for the whole system (hash = -SHA1, sign = -*-SHA1); test
connections from old clients first. On Rocky Linux 8.10 (crypto-policies 20230731), the three lines left
aes256-gcm@openssh.com, chacha20-poly1305@openssh.com, aes256-ctr, aes128-gcm@openssh.com and
aes128-ctr, and none of the SHA-1 key exchanges.
How to check the fix
sudo sshd -T | grep -E '^(ciphers|macs|kexalgorithms) '
On RHEL 8, use the command with $CRYPTO_POLICY from the section above.
From another machine, ssh -vv user@server 2>&1 | grep -E 'kex: algorithm|cipher:' shows what the client and
the server agreed on. ssh-audit lists everything a server offers.
When a warning is fine
When an old client or device has to connect (a network switch, a backup appliance) and cannot be updated.
sshd -t refuses Ciphers, MACs and KexAlgorithms in a Match block, so the old algorithm is offered to
everyone. Let only the address of that device reach the SSH port, accept the result on the dashboard, and plan
to replace the device.
An accepted result stays out of the digest and the counts until it changes.
Sources
- sshd_config(5) (default lists, the
+,-and^prefixes) - OpenSSH release notes (algorithms removed or turned off)
- crypto-policies (policies and
.pmodmodules) - Tested on 2026-11-26 in
rockylinux/rockylinux:8.10.20240528with openssh-server 8.0p1-35.el8_10 and crypto-policies 20230731:sshd.servicewith$CRYPTO_POLICY, theDEFAULT,DEFAULT:NO-SHA1and module lists,Ciphersin aMatchblock (Directive 'Ciphers' is not allowed within a Match block). - ssh-audit