PermitRootLogin default prohibit-password in OpenSSH 7.0 breaks legacy root SSH automation
0 reputation · 04 May 2020, 21:28 UTC
0 reputation · 04 May 2020, 21:28 UTC
OpenSSH 7.0 changed the default for PermitRootLogin from yes to prohibit-password, allowing root login only via key-based authentication when the directive is not explicitly set. A small application with legacy automation that relies on root SSH access is being considered for migration to a host running OpenSSH 7.0 or later.
The change creates a compatibility boundary between the previous default behavior and the stricter default. Maintaining password-based root access preserves existing scripts but conflicts with the security intent of the default. Enforcing the stricter default improves security posture but risks breaking unattended automation that has not been updated to use key authentication.
The decision point is whether to keep the legacy root login behavior or move toward stricter security. Does PermitRootLogin default to prohibit-password on OpenSSH 7.0 and later when the directive is absent from sshd_config? What documented compatibility options exist for legacy root automation without reverting the default to yes? Is there a supported transition approach that avoids downtime for scripts that currently depend on root SSH access?
35275 reputation · 05 May 2020, 05:28 UTC
Yes. Starting with OpenSSH 7.0, when PermitRootLogin is not explicitly set in sshd_config, the effective default is prohibit-password, which allows root login only via public‑key authentication and disables password authentication for the root account.
PermitRootLogin yes (password‑based root login allowed unless overridden).prohibit-password is documented in the OpenSSH 7.0 release notes and the sshd man page.ssh root@host with a password (or sshpass) now fails with "Permission denied (publickey)".The stricter default improves security by preventing brute‑force password attacks on the root account. Scripts that relied on password authentication must either be updated to use key‑based auth or be granted a limited exception that does not weaken the overall default.
sshd -T | grep permitrootlogin
Match block to sshd_config:
Match Address 203.0.113.45
PermitRootLogin yes
Reload the daemon:
systemctl reload sshd
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no root@host true
If the command returns successfully, the exception works./root/.ssh/authorized_keys on the target, ensure the private key is available to the automation script). Test:ssh -i /path/to/automation_key root@host true
Match Address block (or change it to PermitRootLogin prohibit-password) and reload sshd again. This returns the system to the secure default while the automation now uses keys.authorized_keys to a specific command or script, then update the automation to invoke that forced command via SSH. This maintains security without granting broad password access.If you cannot determine whether the automation originates from a known, static IP address, please confirm whether the automation source IP is stable or can be made static; this determines whether a Match Address exception is viable or if a forced‑command key approach is required.
Use comments to ask for clarification. Post a solution as an answer.
6,860 reputation · 04 May 2020, 22:48 UTC
To see what PermitRootLogin is actually in effect, run on the host:
sshd -T | grep permitrootlogin
If the directive is missing, the output will be prohibit-password (synonymous with without-password in older releases). This confirms the new default without touching the config file.
Instead of writing a global PermitRootLogin yes, place a Match block in a dedicated sshd_config.d snippet:
# /etc/ssh/sshd_config.d/legacy-root.conf
Match Address 192.0.2.0/24
PermitRootLogin yes
Because sshd_config.d files are loaded after the main file, the rule overrides the implicit prohibit-password only for the specified subnet. When the automation is migrated to key‑based auth, simply delete the snippet and reload sshd—no downtime.