Weak SSH MAC fallbacks can remain enabled even when ordinary logins appear healthy. The MAC algorithm checks message integrity for non-AEAD SSH traffic, so removing SHA-1, MD5, truncated, and non-policy names keeps remote shells, SFTP transfers, and forwarded sessions from negotiating outdated integrity checks.
OpenSSH exposes the installed algorithm inventory and the daemon policy through different commands. ssh -Q mac lists names compiled into the local client, while sshd -T prints the effective server configuration after defaults, included files, and local overrides are parsed.
The MACs directive replaces the default list unless it starts with +, -, or ^. A strict allowlist is clearer for audit remediation, but it can block older clients and some network appliances. Keep an active session or console path open, test syntax before reload, and use a non-AEAD cipher for the client probe when the test needs to prove MAC negotiation directly.
Related: How to change SSH ciphers
Related: How to enforce strong SSH key exchange algorithms
Tool: SSH Algorithm Policy Checker
$ ssh -Q mac hmac-sha1 hmac-sha1-96 hmac-sha2-256 hmac-sha2-512 hmac-md5 hmac-md5-96 umac-64@openssh.com umac-128@openssh.com hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com umac-64-etm@openssh.com umac-128-etm@openssh.com
This command shows names the binaries understand. It does not prove that sshd offers every listed name to clients.
$ sudo sshd -T port 22 addressfamily any listenaddress [::]:22 listenaddress 0.0.0.0:22 ##### snipped ##### macs umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 ##### snipped #####
The lower-case macs line is the daemon policy after defaults and included configuration files are applied.
Related: How to view SSH server configuration
$ cat /etc/ssh/sshd_config # This is the sshd server system-wide configuration file. ##### snipped ##### Include /etc/ssh/sshd_config.d/*.conf ##### snipped #####
Use the drop-in path when the Include line is active. If the server does not load /etc/ssh/sshd_config.d/*.conf, make the same MACs change in /etc/ssh/sshd_config.
$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
A bad MACs policy can prevent new SSH logins. Keep the current session open and make sure console, rescue, or another administrative path is available.
$ sudoedit /etc/ssh/sshd_config.d/90-mac-algorithms.conf
Use /etc/ssh/sshd_config instead when the server does not include drop-in files.
/etc/ssh/sshd_config.d/90-mac-algorithms.conf MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
This strict allowlist keeps SHA-2 MACs only. Do not use it on hosts that still need UMAC or SHA-1 compatibility without first testing those clients.
sshd_config uses the first value it obtains for most keywords, so the later sshd -T check is the source of truth for which line won.
$ sudo sshd -t
No output means the daemon parsed the configuration and host-key settings successfully.
Related: How to test SSH server configuration
$ sudo systemctl reload ssh
Use sudo systemctl reload sshd on systems that package the service as sshd instead of ssh.
Related: How to manage the SSH server service with systemctl
$ sudo sshd -T port 22 addressfamily any listenaddress [::]:22 listenaddress 0.0.0.0:22 ##### snipped ##### macs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256 ##### snipped #####
$ ssh -o Ciphers=aes256-ctr -o MACs=hmac-sha1 user@host.example.net 'exit' Unable to negotiate with host.example.net port 22: no matching MAC found. Their offer: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256
The forced aes256-ctr cipher keeps MAC negotiation visible for the test. AEAD ciphers such as chacha20-poly1305@openssh.com use implicit integrity and can hide the configured MACs list in verbose output.
$ ssh -o Ciphers=aes256-ctr -o MACs=hmac-sha2-512-etm@openssh.com user@host.example.net 'echo SSH MAC policy accepted' SSH MAC policy accepted