Create an Unprivileged User Account on FreeBSD/OPNsense
On UNIX-like systems it is considered best practice to run daemons and other automated/resident/specialized software under their own, restricted user accounts. This makes it easier to curtail unwanted or unexpected behaviors, whether due to stupidity (bugs) or malice (attack), as the fundamental unit of permissions and access control is the user account. Filesystem permissions, for instance, are determined wholesale at the user and group level. This remains true across flavours and regardless of finer-grained solutions operating at a higher level (RBACs like SELinux, AppArmour, Linux capabilities, etc.) - though they should not be disregarded where enforced.
Conventionally, daemons are assigned a UID below 1000 - where actual, human-operated UIDs begin. It is also common practice to assign no password (represented by an asterisk (*) in the password hash field of the
To line these conditions up with FreeBSD's
Flags employed:
-d - home directory "partition" - create a directory of the same name as the new account under this path./nonexistent -D - do not create a corresponding home directory. This is obviated when specifying/nonexistent with the-d flag.-u - assign a UID from available numbers beginning at the specified number; the default value is0 1000 which is conventionally used to delineate system/unprivileged accounts from fully-fledged, human users. Specifying0 will select the soonest available UID starting from root.-w - disables the password function of the account, effectively rendering it usable but not login-able.no -s - specifies the login shell, in the case of an unprivileged user either/usr/sbin/nologin nologin orfalse - either immediately rejects the login if, for whatever reason or misimplementation, it became possible to log in.
Comments
There are no comments for this item.