{
    "content": [
        {
            "type": "text",
            "text": "# nss-systemd(8) (man)\n\n**Summary:** nss-systemd, libnsssystemd.so.2 - UNIX user and group name resolution for user/group lookup via Varlink\n\n**Synopsis:** libnsssystemd.so.2\n\n## See Also\n\n- systemd(1)\n- systemd.exec(5)\n- nss-resolve(8)\n- nss-myhostname(8)\n- nss-mymachines(8)\n- userdbd.service(8)\n- systemd-homed.service(8)\n- systemd-machined.service(8)\n- nsswitch.conf(5)\n- getent(1)\n\n## Section Outline\n\n- **NAME** (3 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (20 lines)\n- **STATIC DROP-IN JSON USER/GROUP RECORDS** (35 lines) — 2 subsections\n  - CONFIGURATION IN /ETC/NSSWITCH.CONF (17 lines)\n  - EXAMPLE: MAPPINGS PROVIDED BY SYSTEMD-MACHINED.SERVICE (34 lines)\n- **SEE ALSO** (4 lines)\n- **NOTES** (12 lines)\n\n## Full Content\n\n### NAME\n\nnss-systemd, libnsssystemd.so.2 - UNIX user and group name resolution for user/group lookup\nvia Varlink\n\n### SYNOPSIS\n\nlibnsssystemd.so.2\n\n### DESCRIPTION\n\nnss-systemd is a plug-in module for the GNU Name Service Switch (NSS) functionality of the\nGNU C Library (glibc), providing UNIX user and group name resolution for services\nimplementing the User/Group Record Lookup API via Varlink[1], such as the system and service\nmanager systemd(1) (for its DynamicUser= feature, see systemd.exec(5) for details), systemd-\nhomed.service(8), or systemd-machined.service(8).\n\nThis module also ensures that the root and nobody users and groups (i.e. the users/groups\nwith the UIDs/GIDs 0 and 65534) remain resolvable at all times, even if they aren't listed in\n/etc/passwd or /etc/group, or if these files are missing.\n\nThis module preferably utilizes systemd-userdbd.service(8) for resolving users and groups,\nbut also works without the service running.\n\nTo activate the NSS module, add \"systemd\" to the lines starting with \"passwd:\", \"group:\",\n\"shadow:\" and \"gshadow:\" in /etc/nsswitch.conf.\n\nIt is recommended to place \"systemd\" after the \"files\" or \"compat\" entry of the\n/etc/nsswitch.conf lines so that /etc/passwd, /etc/group, /etc/shadow and /etc/gshadow based\nmappings take precedence.\n\n### STATIC DROP-IN JSON USER/GROUP RECORDS\n\nBesides user/group records acquired via the aforementioned Varlink IPC interfaces and the\nsynthesized root and nobody accounts, this module also makes user and group accounts\navailable to the system that are defined in static drop-in files in the /etc/userdb/,\n/run/userdb/, /run/host/userdb/ and /usr/lib/userdb/ directories.\n\nThis is a simple mechanism to provide static user and group records via JSON drop-in files.\nSuch user records should be defined in the format described by the JSON User Records[2]\nspecification and be placed in one of the aforementioned directories under a file name\ncomposed of the user name suffixed with .user, with a world-readable access mode. A symlink\nnamed after the user record's UID formatted in decimal and suffixed with .user pointing to\nthe primary record file should be created as well, in order to allow both lookups by username\nand by UID. Privileged user record data (e.g. hashed UNIX passwords) may optionally be\nprovided as well, in a pair of separate companion files with the .user-privileged suffix. The\ndata should be stored in a regular file named after the user name, suffixed with\n.user-privileged, and a symlink pointing to it, named after the used numeric UID formatted in\ndecimal with the same suffix. These companion files should not be readable to anyone but\nroot. Example:\n\n-rw-r--r--. 1 root root  723 May 10 foobar.user\n-rw-------. 1 root root  123 May 10 foobar.user-privileged\nlrwxrwxrwx. 1 root root   19 May 10 4711.user -> foobar.user\nlrwxrwxrwx. 1 root root   19 May 10 4711.user-privileged -> foobar.user-privileged\n\nSimilarly, group records following the format described in JSON Group Record[3] may be\ndefined, using the file suffixes .group and .group-privileged.\n\nThe primary user/group record files (i.e. those with the .user and .group suffixes) should\nnot contain the \"privileged\" section as described in the specifications. The privileged\nuser/group record files (i.e. those with the .user-privileged and .group-privileged suffixes)\nshould contain this section, exclusively.\n\nNote that static user/group records generally do not override conflicting records in\n/etc/passwd or /etc/group or other account databases. In fact, before dropping in these files\na reasonable level of care should be taken to avoid user/group name and UID/GID conflicts.\n\n#### CONFIGURATION IN /ETC/NSSWITCH.CONF\n\nHere is an example /etc/nsswitch.conf file that enables nss-systemd correctly:\n\npasswd:         compat systemd\ngroup:          compat [SUCCESS=merge] systemd\nshadow:         compat systemd\ngshadow:        files systemd\n\nhosts:          mymachines resolve [!UNAVAIL=return] files myhostname dns\nnetworks:       files\n\nprotocols:      db files\nservices:       db files\nethers:         db files\nrpc:            db files\n\nnetgroup:       nis\n\n#### EXAMPLE: MAPPINGS PROVIDED BY SYSTEMD-MACHINED.SERVICE\n\nThe container \"rawhide\" is spawned using systemd-nspawn(1):\n\n# systemd-nspawn -M rawhide --boot --network-veth --private-users=pick\nSpawning container rawhide on /var/lib/machines/rawhide.\nSelected user namespace base 20119552 and range 65536.\n...\n\n$ machinectl --max-addresses=3\nMACHINE CLASS     SERVICE        OS     VERSION ADDRESSES\nrawhide container systemd-nspawn fedora 30      169.254.40.164 fe80::94aa:3aff:fe7b:d4b9\n\n$ getent passwd vu-rawhide-0 vu-rawhide-81\nvu-rawhide-0:*:20119552:65534:vu-rawhide-0:/:/usr/sbin/nologin\nvu-rawhide-81:*:20119633:65534:vu-rawhide-81:/:/usr/sbin/nologin\n\n$ getent group vg-rawhide-0 vg-rawhide-81\nvg-rawhide-0:*:20119552:\nvg-rawhide-81:*:20119633:\n\n$ ps -o user:15,pid,tty,command -e|grep '^vu-rawhide'\nvu-rawhide-0      692 ?        /lib/systemd/systemd\nvu-rawhide-0      731 ?        /lib/systemd/systemd-journald\nvu-rawhide-192    734 ?        /lib/systemd/systemd-networkd\nvu-rawhide-193    738 ?        /lib/systemd/systemd-resolved\nvu-rawhide-0      742 ?        /lib/systemd/systemd-logind\nvu-rawhide-81     744 ?        /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only\nvu-rawhide-0      746 ?        /usr/sbin/sshd -D ...\nvu-rawhide-0      752 ?        /lib/systemd/systemd --user\nvu-rawhide-0      753 ?        (sd-pam)\nvu-rawhide-0     1628 ?        login -- zbyszek\nvu-rawhide-1000  1630 ?        /lib/systemd/systemd --user\nvu-rawhide-1000  1631 ?        (sd-pam)\nvu-rawhide-1000  1637 pts/8    -zsh\n\n### SEE ALSO\n\nsystemd(1), systemd.exec(5), nss-resolve(8), nss-myhostname(8), nss-mymachines(8), systemd-\nuserdbd.service(8), systemd-homed.service(8), systemd-machined.service(8), nsswitch.conf(5),\ngetent(1)\n\n### NOTES\n\n1. User/Group Record Lookup API via Varlink\nhttps://systemd.io/USERGROUPAPI\n\n2. JSON User Records\nhttps://systemd.io/USERRECORD\n\n3. JSON Group Record\nhttps://systemd.io/GROUPRECORD\n\n\n\nsystemd 249                                                                           NSS-SYSTEMD(8)\n\n"
        }
    ],
    "structuredContent": {
        "command": "nss-systemd",
        "section": "8",
        "mode": "man",
        "summary": "nss-systemd, libnsssystemd.so.2 - UNIX user and group name resolution for user/group lookup via Varlink",
        "synopsis": "libnsssystemd.so.2",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "systemd",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/systemd/1/json"
            },
            {
                "name": "systemd.exec",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/systemd.exec/5/json"
            },
            {
                "name": "nss-resolve",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/nss-resolve/8/json"
            },
            {
                "name": "nss-myhostname",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/nss-myhostname/8/json"
            },
            {
                "name": "nss-mymachines",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/nss-mymachines/8/json"
            },
            {
                "name": "userdbd.service",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/userdbd.service/8/json"
            },
            {
                "name": "systemd-homed.service",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/systemd-homed.service/8/json"
            },
            {
                "name": "systemd-machined.service",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/systemd-machined.service/8/json"
            },
            {
                "name": "nsswitch.conf",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/nsswitch.conf/5/json"
            },
            {
                "name": "getent",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/getent/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "STATIC DROP-IN JSON USER/GROUP RECORDS",
                "lines": 35,
                "subsections": [
                    {
                        "name": "CONFIGURATION IN /ETC/NSSWITCH.CONF",
                        "lines": 17
                    },
                    {
                        "name": "EXAMPLE: MAPPINGS PROVIDED BY SYSTEMD-MACHINED.SERVICE",
                        "lines": 34
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 12,
                "subsections": []
            }
        ]
    }
}