Skip to content

nss-systemd can make sshd treat the root account as locked #92

@angelsl

Description

@angelsl

On my Debian 12 system, /etc/nsswitch.conf (on the system) has

passwd:         files systemd
group:          files systemd
shadow:         files systemd
gshadow:        files systemd

Normally /etc/nsswitch.conf isn't included in the initramfs, but some dracut modules cause it to be pulled in, e.g. the nfs module.

nss-systemd by default returns a synthetic entry for root shadow:

# getent -s systemd shadow root
root:!*:::::::

which as we know causes opensshd to refuse logins as root.

Two things need to be true for this to happen:

  1. your initramfs has no /etc/shadow (or /etc/shadow has no entry for root)
  2. your initramfs gets a /etc/nsswitch.conf that has systemd as a source for the shadow database

...of which (2) became true for me after I set up NFS one random day, and then I spent a few hours trying to figure out why sshd was saying root was locked.

Just leaving this here in case someone else runs into this issue..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions