Audit Ubuntu SSH for Weak Ciphers and MACs
Securing your Ubuntu SSH server requires identifying and disabling obsolete cryptographic algorithms. This guide provides a straightforward walkthrough on how to audit your Ubuntu Linux SSH server configuration for weak ciphers and Message Authentication Codes (MACs), check your active settings, use automated auditing tools, and update your configuration to enforce modern security standards.
Step 1: View Currently Enabled Ciphers and MACs
Before making changes, check which algorithms your SSH daemon
(sshd) currently supports and accepts. Run the following
commands to output the active configuration:
To view configured ciphers:
sshd -T | grep ciphersTo view configured MACs:
sshd -T | grep macsThe output will display a comma-separated list of algorithms. If you
see weak algorithms like 3des-cbc, aes128-cbc,
hmac-md5, or hmac-sha1, your server is
vulnerable to cryptographic attacks.
Step 2: Scan the SSH Server Using ssh-audit
An effective way to audit your SSH server is by using ssh-audit, an open-source tool that scans SSH servers for weak configuration settings, outdated algorithms, and security vulnerabilities.
Install ssh-audit
On modern Ubuntu systems, you can install it directly via the package manager:
sudo apt update
sudo apt install ssh-auditAlternatively, you can run it using Python if the package is not in your repository:
wget https://github.com/jtesta/ssh-audit/releases/latest/download/ssh-audit.py
chmod +x ssh-audit.pyRun the Scan
Run the tool against your local or remote SSH port (default is 22):
ssh-audit localhostThe output will color-code the results. Green indicates secure algorithms, yellow indicates warning-level algorithms (often kept for legacy compatibility), and red highlights critical vulnerabilities (weak ciphers/MACs) that must be disabled immediately.
Step 3: Disable Weak Ciphers and MACs
To secure your server, you must explicitly define only strong, modern algorithms in the SSH configuration file.
Open the SSH daemon configuration file with root privileges:
sudo nano /etc/ssh/sshd_configScroll to the bottom of the file or look for existing
CiphersandMACsdirectives. If they do not exist, add the following lines to enforce secure, modern standards:# Secure Ciphers Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com # Secure MACs MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.comSave the file and exit the editor (in nano, press
Ctrl+O,Enter, thenCtrl+X).
Step 4: Test and Apply Configuration Changes
Always test your SSH configuration before restarting the service to ensure there are no syntax errors that could lock you out of the server.
Test the configuration file:
sudo sshd -tIf the command returns no output, the syntax is correct. You can now safely restart the SSH service to apply the changes:
sudo systemctl restart sshStep 5: Verify the Hardened Configuration
Re-run the audit tool to confirm that all weak ciphers and MACs have been successfully removed:
ssh-audit localhostThe report should now show only green ratings for your SSH ciphers and MACs, indicating a hardened SSH server configuration.