NSSCACHE.CONF(5)
π NSSCACHE.CONF(5) π
okay bestie, buckle UP β this is the manual page for nsscache.conf, and it's giving file formats energy in the best way possible π
β¨ NAME β¨
nsscache.conf β the NSS local cache synchroniser configuration file, aka the glow-up your name service lookups have been begging for π¦
β¨ SYNOPSIS β¨
/etc/nsscache.conf
that's it. that's the whole synopsis. iconic, honestly π
β¨ DESCRIPTION β¨
So here's the vibe: nsscache synchronises a local NSS cache (and other databases too, it's multitasking like a queen π) against a remote data source. Why do we care? Because this approach lets the admin separate the network from the NSS lookup codepath, which improves both the speed and the reliability of name services. no more waiting on the network every single time you want to know who somebody is. periodt.
The nsscache configuration file is made of one DEFAULT section, followed by zero or more map-specific configuration sections. The file format is similar to that of .ini files, so if you've ever written one of those, you already know the shape of it.
The DEFAULT section must provide at least:
- one
sourcekeyword β specifying the data source to use - one
cachekeyword β specifying the means in which the cache data will be stored locally - one
mapskeyword β specifying which NSS maps should be cached - one
timestamp_dirkeyword β specifying the location of the timestamps used for incremental updates
Additional global defaults may also be included in the DEFAULT section β stuff like LDAP search parameters, or the filesystem location of the cache. go wild, it's your default zone π
Additional sections may be included that allow per-map overrides to configuration options. For example, one might specify their global LDAP search base as ou=People but want to override that for the group mapping as ou=Groups. see? flexible. main character behaviour. π
Apart from the source, cache, and maps configuration options, all options are prefixed by the name of the module that they configure. iykyk.
A complete list of configuration options follows. let's get into it, bestie πΈ
β¨ DEFAULT-only OPTIONS β¨
These ones live in DEFAULT and DEFAULT only, no exceptions π
sourceβ Specifies the source to use to retrieve NSS data from.
Valid Options: ldap, s3, http, gcs
cacheβ Specifies the cache method to use to store the data, which will be queried by the NSS itself.
Valid options: files β Store in a plain text file, similar in format to /etc/passwd. If the files-module option files_cache_filename_suffix is also set to cache then not only will the files be created with a .cache suffix, but also an index file will be written alongside, for use with the nss-cache NSS module. (See https://github.com/google/libnss-cache.)
mapsβ Specifies the names of the maps that will be queried and cached bynsscache
Valid options: passwd group shadow netgroup automount sshkey
timestamp_dirβ Specifies the directory where update and modify timestamps are stored. β°
β¨ ldap SOURCE OPTIONS β¨
These options configure the behaviour of the ldap source. so many options, so much power π§
ldap_adβ Set to1if connecting to Active Directory. If enabled, default Active Directory attributes will be used for mapping. Leave disabled if connecting to openldap.ldap_uriβ The LDAP URI to connect to.ldap_baseβ The base to perform LDAP searches under.ldap_filterβ The search filter to use when querying.ldap_scopeβ The search scope to use. Defaults toone
Valid options: sub[tree] one[level] base
ldap_bind_dnβ The bind DN to use when connecting to LDAP. Empty string is an anonymous bind. Defaults to the empty string.ldap_bind_passwordβ The bind password to use when connecting to LDAP. Empty string is used for anonymous binds. Defaults to the empty string.ldap_timelimitβ Timelimit in seconds for search results to return.-1means no limit. Defaults to-1.ldap_retry_maxβ Number of retries on soft failures before giving up. Defaults to3.ldap_retry_delayβ Delay in seconds between retries. Defaults to5.ldap_tls_require_certβ Sets expectations for SSL certificates, using TLS. One of'never','hard','demand','allow', or'try'('demand'is the default). Seeldap.conf(5)for more information.ldap_tls_cacertdirβ Directory for trusted CA certificates. By default, the system's default CA certificate directory will be used.ldap_tls_cacertfileβ Filename containing trusted CA certificates.ldap_tls_certfileβ Filename of an optional LDAP client certificate. If specified,ldap_tls_keyfilemust also be specified.ldap_tls_keyfileβ Filename of an optional LDAP client key. Only plaintext (unencrypted) keys are currently supported. If specified,ldap_tls_certfilemust also be specified.ldap_tls_starttlsβ Set to1to enable STARTTLS. Leave absent to disable.ldap_uidattrβ The uid-like attribute in your directory. Defaults touid.ldap_use_ridβ If enabled (set to1) the relative identifier (RID) wll be used for mapping. By defaultuidNumberandgidNumberwill be mapped when connecting to OpenLDAP with a POSIX-like schema. When using Samba4 AD, these attributes won't exist. Leave disabled for default. It has no effect if the optionldap_adis enabled.ldap_offsetβ Default Offset option to mapuidNumberandgidNumberto higher number. This can be useful to avoid conflict with already existinguidNumberandgidNumber.ldap_uidregexβ A Python regex to extract uid components from the uid-like attribute. All matching groups are concatenated without spaces. For example:'(.*)@example.com'would return a uid to the left of the@example.comdomain. Default is no regex.ldap_groupregexβ A Python regex to extract group member components from thememberormemberOfattributes. All matching groups are concatenated without spaces. For example:'(.*)@example.com'would return a member without the the@example.comdomain. Default is no regex.ldap_nested_groupsβ To enable expansion of nested groups, set this to1. Note that this only applies during a full sync, and incremental synchronization should not be used if this is set.
β οΈ bestie, pay attention to that one: nested group expansion only applies during a full sync, and if you set this, incremental synchronization should not be used. no cap.
ldap_override_shellβ If specified, set every user's login shell to the given one. May be useful on bastion hosts or to ensure uniformity. Enable for Active Directory since the attribute (loginShell) is not default.ldap_home_dirβ Set a home directory for all users in passwd. If enabled (set to1), all users will have their home directory in/home.ldap_rfc2307bisβ Default uses rfc2307 schema. If rfc2307bis (groups stored as a list of DNs in'member'attr), set this to1.ldap_debugβ Sets the debug level for the underlying C library. Defaults to no logging.
β¨ s3 SOURCE OPTIONS β¨
These options configure the behaviour of the s3 source. cloud storage moment βοΈβ¨
s3_bucketβ AWS S3 bucket containingpasswd,group,shadowobjects.boto3python package should be installed to use this type of source. It is highly recommended to use s3 source only with AWS IAM role attached to the ec2 instance configured for read-only access to the bucket. So no extra configuration options likeaccess_keyandsecretprovided in config. Though they may be used via~/.aws/configand~/.aws/credentialsbecause python boto3 library used in implementation is capable to read them by itself.s3_passwd_objectβ Object containing passwd array of records in json format. E.g.[{"Value": {"gid": 10000, uid : 10000}, Key : user1 }]. Valid attributes:comment,home,shell,passwd,gid,uids3_group_objectβ Object containing group array of records in json format. E.g.[{"Value": {"gid": 20000, members : user10ser20ser3 }, Key : group1 }]. Valid attributes:gid,membersMembers should be sequence of usernames split by\n(see example above)s3_shadow_objectβ Object containing shadow array of records in json format. E.g.[{"Value": {"passwd": * }, Key : user1 }]. Valid attributes:passwd,lstchg,min,max,warn,inact,expires3_sshkey_objectβ Object containing sshkey array of records in json format. E.g.[{"Value": {"sshPublicKey": ssh-rsa ... }, Key : user1 }]. Valid attributes:sshPublicKey
β¨ http SOURCE OPTIONS β¨
These options configure the behaviour of the http source. just grab it off the web, bestie π
http_passwd_urlβ URL for an HTTP endpoint that returns a file containing passwd records in the standard format. E.g.root:*:0:0:System Administrator:/var/root:/bin/shhttp_group_urlβ URL for an HTTP endpoint that returns a file containing group records in the standard format. E.g.users:x:100:memberships....http_shadow_urlβ URL for an HTTP endpoint that returns a file containing shadow records in the standard format. E.g.root:*:18866:0:99999:7:::http_sshkey_urlβ URL for an HTTP endpoint that returns a file containing sshkey records in the standard format. E.g.root:ssh-rsa ...
β¨ files CACHE OPTIONS β¨
These options configure the behaviour of the files cache. plain text, my beloved π
files_dirβ Directory location to store the plain text files in. Defaults to the current directory.files_cache_filename_suffixβ A suffix appended to the cache filename to differentiate it from, say, system NSS databases. Defaults to'.cache'.files_local_automount_masterβ A yes/no field only used for automount maps. A'yes'value will causensscacheto update theauto.masterfile with the master map from the source. A'no'value will causensscacheto leaveauto.masteralone, allowing the system to manage this file in other ways. When set to'no',nsscachewill only update other automount maps defined both locally and in the source. Defaults to'yes'.prefixβ A regular expression to capture a prefix, or mount point.suffixβ A regular expression to modify the prefix.
β¨ EXAMPLE β¨
A typical example might look like this:
[DEFAULT]
source = ldap
cache = files
maps = passwd, group, shadow
ldap_uri = ldap://ldap.example.com
ldap_base = ou=People,dc=example,dc=com
ldap_filter = (objectclass=posixAccount)
files_dir = /etc
files_cache_filename_suffix = cache
[group]
ldap_base = ou=Group,dc=example,dc=com
ldap_filter = (objectclass=posixGroup)
ldap_nested_groups = 1
[shadow]
ldap_filter = (objectclass=posixAccount)
And a complementary /etc/nsswitch.conf might look like this:
passwd: files cache
group: files cache
shadow: files cache
look at that. a whole working config. you ate. π β¨
and that's part one, bestie β more still to come, so don't go anywhere π«Ά
β¨ gcs SOURCE OPTIONS β¨
okay bestie so this is the gcs source block β it's where you tell nsscache how to vibe with Google Cloud Storage buckets π«Ά these options configure the behaviour of the gcs source, periodt.
gcs_bucketβ the Google Cloud Storage bucket holding yourpasswd,group, andshadowblobs. like, the whole lil home for your identity files π and it comes with three sub-options, all of them nuzzled up under it:gcs_passwd_objectβ the name of the object that containspasswdrecords in the standard format. for example:
root:*:0:0:System Administrator:/var/root:/bin/sh
gcs_group_objectβ the name of the object that containsgrouprecords in the standard format. for example:
users:x:100:memberships....
gcs_shadow_objectβ the name of the object containingshadowrecords in the standard format. for example:
root:*:18866:0:99999:7:::
π FILES π
/etc/nsscache.confβ the system-wide nsscache configuration file. yes, the one. the main character config fr fr π
π SEE ALSO π
nsscache(1)β the main event, the big sister page πnsswitch.conf(5)β the system name service switch configuration file. it's giving gatekeeper energy but make it helpful πldap.conf(5)β all the details on LDAP configuration options exposed by the LDAP client libraries. iykyk π§
βοΈ AUTHOR βοΈ
Written by Jamie Wilkinson (jaq@google.com) and Vasilios Hoffman (vasilios@google.com). legends, honestly π
The source code lives at https://github.com/google/nsscache β go peek, it's lowkey iconic π
Β©οΈ COPYRIGHT Β©οΈ
Copyright Β© 2007 Google, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. like, zero warranty bestie, none, nada, not even the tiniest crumb π read the fine print and respect it π
and that's a wrap on NSSCACHE.CONF(5) π¬ this lil beauty is from nsscache 0.49, dated 2023-06-03 β screenshot it, bookmark it, tattoo it on your forearm, whatever works for you. go forth and switch your name services with main character energy, bestie π
β¨π¦πΈ
π¦ where this page comes from
- debian trixie: nsscache 0.49-5 Β· GPL-2.0-or-later
- ubuntu noble: nsscache 0.49-2 Β· GPL-2.0-or-later
- ubuntu questing: nsscache 0.49-5
- ubuntu resolute: nsscache 0.49-5build1 Β· GPL-2.0-or-later
- ubuntu stonking: nsscache 0.49-5build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms