The SSH daemon (sshd) failed to start because its associated unprivileged user, sshd, which is required for privilege separation, was not found in the system’s user database.
This error, sshd: error: [User sshd does not exist], typically means the sshd process, when trying to drop its root privileges for security, cannot find the dedicated sshd user account it’s supposed to switch to. This user account is a fundamental part of SSH’s security model, ensuring that even if the unprivileged part of sshd is compromised, the attacker doesn’t gain root access.
Here are the most common reasons this happens and how to fix them:
-
The
sshduser was accidentally deleted. This is the most straightforward cause. The user account, along with its associated group, is usually created by the SSH package installation. If it was manually removed or if a system cleanup script was overly aggressive, it will be gone.-
Diagnosis: Check if the user and group exist:
grep sshd /etc/passwd grep sshd /etc/groupIf you see no output, the user/group is missing.
-
Fix: Recreate the
sshduser and group. The exact UID/GID might vary slightly by distribution, but typically they are low numbers. A common and safe approach is to use theuseraddcommand. For Debian/Ubuntu-based systems:sudo groupadd --system sshd sudo useradd --system -g sshd -d /var/empty -s /usr/sbin/nologin sshdFor RHEL/CentOS/Fedora-based systems:
sudo groupadd -r sshd sudo useradd -r -g sshd -d /var/empty -s /usr/sbin/nologin sshdThe
--systemor-rflag ensures it’s a system account./var/emptyis a standard, empty directory for such users, and/usr/sbin/nologinprevents interactive logins. -
Why it works: This manually recreates the necessary user and group entries in
/etc/passwdand/etc/group, satisfyingsshd’s requirement for a user to switch to.
-
-
The
sshduser’s UID/GID is conflicting or has been changed incorrectly. Sometimes, the user or group exists but has an invalid UID or GID, or it conflicts with another system user/group, causingsshdto fail when it tries to resolve it.-
Diagnosis: Examine the
sshdentry in/etc/passwdand/etc/group.grep sshd /etc/passwd grep sshd /etc/groupNote the UID and GID. Then check for other users/groups with the same UID/GID:
grep ":<sshd_uid>:" /etc/passwd grep ":<sshd_gid>:" /etc/group(Replace
<sshd_uid>and<sshd_gid>with the actual numbers from the previous step.) -
Fix: If there’s a conflict or the entry is malformed, you’ll need to correct it. If the user/group exists but has a bad UID/GID, you can try to reassign it. For example, to change the UID of the
sshduser to65534and its GID to65534(common for unprivileged system users):sudo usermod -u 65534 sshd sudo groupmod -g 65534 sshdIf the user/group is truly corrupted or missing, refer to fix #1.
-
Why it works: This ensures that the
sshduser and group have unique, valid identifiers thatsshdcan reliably use to switch contexts.
-
-
Incorrect
sshd_configdirective forPrivilegeSeparationorUsersettings. Whilesshddefaults to using a user namedsshdfor privilege separation, it’s possible that a misconfiguration insshd_configis pointing to a non-existent user or has disabled privilege separation incorrectly.-
Diagnosis: Inspect your SSH server configuration file, usually
/etc/ssh/sshd_config.sudo grep -E 'PrivilegeSeparation|User' /etc/ssh/sshd_configLook for lines like
PrivilegeSeparation yes(orno) and anyUserdirectives that might be interfering. IfPrivilegeSeparationis set toyesand there’s noUserdirective specifying a different unprivileged user, it must find thesshduser. -
Fix: Ensure
PrivilegeSeparationis set toyesand that no otherUserdirective is overriding the defaultsshduser without also defining a valid alternative. If you find a line likeUser someotheruser, andsomeotheruserdoesn’t exist, either remove the line or createsomeotheruser. For standard setups, it should look like this:PrivilegeSeparation yesIf you explicitly want to use a different user, e.g.,
nobody, ensure that user exists and configure it:PrivilegeSeparation yes User nobodyAfter modifying
/etc/ssh/sshd_config, you must reload or restartsshd:sudo systemctl reload sshd # or sudo systemctl restart sshd -
Why it works: This ensures the
sshddaemon is configured to use privilege separation and that it’s looking for a user that actually exists on the system.
-
-
The
sshdpackage is corrupted or incompletely installed. In rare cases, the installation of theopenssh-serverpackage might have failed partway, preventing thesshduser from being created or the necessary configuration files from being set up correctly.-
Diagnosis: Check the package manager’s status. For Debian/Ubuntu:
dpkg -s openssh-server | grep StatusFor RHEL/CentOS/Fedora:
rpm -q openssh-serverIf the package is listed as "not installed" or has errors, this is the cause.
-
Fix: Reinstall the
openssh-serverpackage. This will usually recreate the necessary user and configuration. For Debian/Ubuntu:sudo apt-get update sudo apt-get --reinstall install openssh-serverFor RHEL/CentOS/Fedora:
sudo yum reinstall openssh-server # or sudo dnf reinstall openssh-serverYou might need to reapply any custom
sshd_configsettings after reinstallation. -
Why it works: Reinstalling the package ensures that all components, including the
sshduser and default configuration, are properly set up according to the package’s design.
-
-
SELinux or AppArmor restrictions preventing user creation/lookup. Security modules like SELinux or AppArmor can sometimes interfere with system processes, including user management or the
sshddaemon’s ability to identify its required unprivileged user.-
Diagnosis: Check system logs for SELinux or AppArmor denials related to
sshd. For SELinux:sudo ausearch -m avc -ts recent | grep sshdOr check
/var/log/audit/audit.log. For AppArmor:sudo dmesg | grep -i apparmor | grep sshdOr check
/var/log/syslogor/var/log/messages. -
Fix: If you find denials, you’ll need to adjust the security policy. For SELinux, this might involve restoring default contexts or installing specific policy modules. For example, if the
sshduser context is wrong, you might try:sudo restorecon -Rv /etc/passwd /etc/groupIf SELinux is the persistent issue, temporarily setting it to permissive mode (
sudo setenforce 0) can help confirm, but the proper fix is to adjust policies. For AppArmor, you might need to edit thesshdprofile in/etc/apparmor.d/. Consult your distribution’s documentation for specific SELinux/AppArmor troubleshooting. -
Why it works: This removes the security policy barriers that prevent
sshdfrom correctly interacting with the system’s user database or thesshduser itself.
-
After applying any of these fixes, attempt to start or restart the SSH service:
sudo systemctl start sshd
# or
sudo systemctl restart sshd
If the sshd user was the problem, the next error you’ll likely encounter if sshd starts successfully is related to sshd not being able to bind to the network port (e.g., Address family not supported by protocol or Address already in use), which indicates a network configuration issue or another service occupying the port.