Cybermatic.aiAll guides →

The Cybermatic Signal · Fix-it Guides · Devices · Linux

How to disable empty password logins over SSH on Linux

← All guides · Time to fix: 5 minutes per server · Linux

The SSH daemon has a setting called PermitEmptyPasswords that controls whether accounts with no password set can log in over the network. Any Linux server running OpenSSH is potentially affected if the setting is missing or left at its default commented-out state. The fix takes about five minutes per server and requires only a text editor or a single command.

The fix, verified

SSH permits empty passwords

Severitycritical · Linux
Or run
sudo sed -i 's/^#\?PermitEmptyPasswords.*/PermitEmptyPasswords no/' /etc/ssh/sshd_config && sudo systemctl reload sshd
Maps toCIS Linux 5.2.9

What this setting does and what goes wrong when it is misconfigured

When PermitEmptyPasswords is set to yes, or when the line is absent and a downstream configuration file enables it, SSH will authenticate any user whose password field in /etc/shadow is empty — no password required, just a valid username. On a server where a service account was created without a password, or where a password was accidentally cleared during a user-management task, that account becomes an open door. An attacker scanning port 22 with a list of common usernames can walk straight in. If that account happens to be root, or if the account can sudo, the server is fully compromised without any brute-force effort at all. A realistic scenario: a developer spins up a test VM, creates a local account for quick access, never sets a password, and then that VM gets promoted to handle a production workload. The account is still there, still passwordless, and SSH is still listening.

How to check whether you are affected

Run the following command to see the effective value. A result of 'PermitEmptyPasswords yes' means you are exposed. No output, or a commented-out line, means the compiled-in default applies — which is 'no' in most modern OpenSSH builds, but you should still set it explicitly so it cannot be overridden by a drop-in file under /etc/ssh/sshd_config.d/.

Also check for accounts that actually have empty passwords, because fixing SSH does not remove the underlying risk:

Any username returned by that command should have a password set or be locked with 'sudo passwd -l <username>' before you proceed.

How to fix it

The command below finds the PermitEmptyPasswords line in /etc/ssh/sshd_config — whether it is active or commented out — replaces it with the explicit 'no' value, and then reloads the SSH daemon without dropping existing sessions:

sudo sed -i 's/^#\?PermitEmptyPasswords.*/PermitEmptyPasswords no/' /etc/ssh/sshd_config && sudo systemctl reload sshd

After running it, verify the change took effect:

The output should read 'permitemptypasswords no'. The sshd -T flag prints the full runtime configuration, so it catches values set in included files as well.

What might break and how to avoid it

The only accounts that will lose SSH access are those with empty passwords. Legitimate users with properly set passwords are not affected. Before reloading sshd, confirm that every account used for SSH access has a password or uses key-based authentication. If you are managing service accounts that rely on passwordless local sudo rather than SSH, those are unaffected — this setting only governs remote SSH logins. Keep your current SSH session open while you test a second login in a separate terminal before closing anything.

How to keep it fixed

For a single server, the sed command above is sufficient. For a fleet, push the setting through your configuration management tool — Ansible, Puppet, Chef, or SaltStack can all enforce a line in sshd_config across every managed host and verify it on each run. If you use a cloud provider's image pipeline, bake the setting into your base image so new instances start compliant. Schedule a quarterly audit using the grep command above against all servers, or add it to your monitoring system as a file-integrity check on /etc/ssh/sshd_config. This control maps to CIS Linux Benchmark section 5.2.9, so if you run CIS-CAT or a similar scanner it will flag any regression automatically.

Is this open in your environment?

Cybermatic checks for "SSH permits empty passwords" automatically — on every device, every day — and shows you the exact fix above next to each one it finds. The free scan takes about ten minutes and needs no credit card.

Run the free scan All guides →

Part of The Cybermatic Signal. Written by the Cybermatic editorial agent from the configuration check Cybermatic runs for this setting (ID lin-ssh-emptypwd) and reviewed before publication. The click path, command and caution in the fix card are the vendor's documented procedure as of 2026-11-14. Found an error? Write to info@cybermatic.ai.

BriefingIssuesFlashGuidesInsurance checkDomain checkSubscribe

Cybermatic.ai by Ironhawk Group · 9330 Lyndon B Johnson Fwy, Suite 900 · Dallas, TX 75243 · Privacy · cybermatic.ai