Users and Groups
Users and Groups
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
– Output of sudo(8) upon first invocation.
6.1 Introduction
As was noted in Section 2.2.3, Unix was designed as a multi-tasking, multi-
user system, allowing simultaneous access by di↵erent people. This concept,
also found in all of today’s mainstream operating systems as well, demands
important safeguards to prevent both accidental as well as intentional (i.e.
malicious) access by unauthorized parties. Since this property a↵ects virtu-
ally all aspects of system administration – ranging from account management
to the way di↵erent software components interact with one another – it is
important to fully understand the implications of the nature of a multi-user
system.
In this chapter, we will discuss the di↵erent types of users and groups as
well as talk about user authentication on our systems. Note that even though
there are many parallels to authentication by remote clients against a service
we may o↵er (such as users logging into our website), in this chapter we
restrict ourselves to the “local” systems and how we access them internally.
Even if you are comfortable with the Unix multi-user model, you may still
170
CHAPTER 6. OF USERS AND GROUPS 171
find that explicitly identifying its inherent requirements and trust models
will help in formalizing your access control requirements so as to express and
apply them using your configuration management system, as discussed in the
Chapter 7.
As one of our Pillars of Exceptional System Design, the topic of security
weaves through this book like a red thread, and multi-user principles and the
implications of di↵erent access- and trust levels necessitate a look ahead at
topics and ideas discussed in more detail in Chapter 11.1. Hence, discussing
the core concepts of authentication and authorization is a natural requirement
and we will attempt to broadly cover them in this chapter as well. But let’s
not get ahead of ourselves...
Figure 6.1: The set of users mapping to the set of account names is neither
bijective (or “one-to-one”), nor surjective (or “onto”): some accounts are
not used by an actual user, while others may be used by more than one user.
Users are associated with local groups on a given host, and group membership
may imply specific privileges across a set of hosts.
of the file system – see, for example, the chroot(8) command. In the past, assigning a
user a so-called restricted shell was another method of limiting what actions a user may
perform.
CHAPTER 6. OF USERS AND GROUPS 175
In contrast to these use cases, now consider the di↵erent groups of users
present in an academic environment, such as a large university. Access to
computing resources is made available to students, faculty, sta↵, and possibly
visiting researchers. Even disregarding any outside compromise, you have at
times almost directly conflicting privacy requirements: students should not
be able to access faculty resources or files (and yet may have an explicit
interest in doing so!), but students working as teaching or faculty assistants
sometimes should; student homework assignments done on shared servers
should not prevent research jobs from running; faculty may collaborate with
each other on some projects, with outside researchers on others.
Finally, if you are maintaining public systems for an Internet Service
Provider (ISP), you may find yourself trying to manage hundreds or thou-
sands of completely unrelated user accounts with little to no collaboration
amongst them.
Group definitions exist in every organization, and are often drawn outside
the system administrator’s purview; it is not uncommon for computer sys-
tems to inherit a group structure by mapping the organization’s functional
hierarchy into di↵erent user groups. However, sooner or later you will run
into limitations and require more fine-grained control. A careful analysis of
the di↵erent types of users, the di↵erent groups based on requirements and
needs, and a directory service that allows you to easily create (possibly in-
tersecting) sets of users are needed to allow your systems to grow with and
adapt to the needs of whichever type of environment you are in. We will
get back to this concept of grouping users and mapping them to similarly
grouped sets of hosts in our next chapter.
And then there’s the start-up founder, who not only routinely tinkers
with the OS kernel and system configurations, but oversees the hardware
allocation requests in what has become an Internet giant with tens of
thousands of hosts in data centers across the globe:
Every system administrator I know has a similar story to tell; they fre-
quently end with “Well, he doesn’t need access, but he’s the boss, so...”.
Each authentication method has its own strengths and weaknesses, with
usability and convenience being important factors upon the final security
they may provide: passwords that are easy to remember are also easy to
guess or crack, physical tokens can be lost or stolen, and biometric factors
are near impossible to replace or change in case of a compromise.
In many cases, it is desirable to combine some of these authentication
methods to yield the desired level of security and usability. So-called “two-
factor authentication” or 2FA has recently become a popular protection
mechanism used by many internet sites: in order to gain access to a ser-
vice, the user needs to provide e.g. a password (something you know) as well
as a code generated by an app on their smartphone (the phone thus being
something you have). It is entirely possible – and at times desirable – to add
more factors or vary combinations of factors, which is why the more general
term “multi-factor authentication” (MFA) is more precise.
Lastly, let us note that even though we frequently only consider authenti-
cation of one party, mutual authentication is an often desired or even required
property of a secure system: when a user logs into a system, the system wishes
to authenticate the user, but the user also needs to have assurance that the
system they are logging in to is the system they think it is.
4
Unlike the system administrator in charge, the computer does not care if Alice gives
her credentials to Bob and allows him to log in as her.
5
Cynical information security professionals, always happy to point out weaknesses in
any system, like to refer to these categories as “something you forgot, something you lost,
something you stopped being”.
CHAPTER 6. OF USERS AND GROUPS 179
NetBSD/amd64 (SERVER) ( c o n s o l e )
l o g i n : jschauma
password : ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤
NetBSD 7 . 0 . 2 (SERVER) #2: Tue Jan 24 0 2 : 3 3 : 1 3 EST 2017
Welcome t o NetBSD !
hostname$
$ ssh i ˜ / . s s h /mykey s e r v e r
The a u t h e n t i c i t y o f h o s t ’ s e r v e r ( 1 9 2 . 0 . 2 . 1 2 ) ’ can ’ t be e s t a b l i s h e d .
ECDSA key f i n g e r p r i n t i s 1 9 : a f : 3 5 : 0 1 : 0 b : 2 a : e e : 3 d : 3 0 : 0 f : 6 9 : 1 1 : c c : 5 5 : 7 c : 2 0 .
Are you s u r e you want t o c o n t i n u e c o n n e c t i n g ( y e s / no ) ? yes
NetBSD 7 . 0 . 2 (SERVER) #2: Tue Jan 24 0 2 : 3 3 : 1 3 EST 2017
Welcome t o NetBSD !
hostname$
$ kinit
Password f o r jschauma@DOMAIN : ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤
$ klist
T i c k e t c a c h e : /tmp/ k r b 5 c c t t y p a
D e f a u l t p r i n c i p a l : jschauma@DOMAIN
l o c a l h o s t $ ssh sshca
YubiKey f o r ‘ jschauma ’ : ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤
Password : ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤ ⇤
l o c a l h o s t $ ssh add l
2048 SHA256 : TzwuHGc5BKBe+VJSnGoVyh92J8XKBUkaL7MGQn8ML0Y (RSA)
2048 SHA256 : TzwuHGc5BKBe+VJSnGoVyh92J8XKBUkaL7MGQn8ML0Y (RSA CERT)
l o c a l h o s t $ s s h somehost
Duo two f a c t o r l o g i n f o r jschauma
Enter a p a s s c o d e o r s e l e c t one o f t h e f o l l o w i n g o p t i o n s :
somehost$
From that moment on, regular Unix semantics and permissions will apply to
decide whether or not access to a given resources (e.g. the ability to write to
a file) is granted.
Passwords are an easy and convenient way for users to authenticate to a
system. However, there are quite a few drawbacks that it is important to be
consciously aware of.
As noted above, we do not actually store clear text passwords in a database,
as this would mean that anybody (and any process) able to access this
database had access to all users’ passwords. Instead, the use of a hash en-
sures that even using a privileged account, we cannot see the users’ clear
text passwords. Still, we wish to protect the password hashes from prying
eyes, which is why our Unix systems no longer store them in the world-
readable /etc/passwd database, but instead in a separate, protected file
(such as /etc/master.passwd on BSD derived systems or /etc/shadow on
many System V derived Unix versions).
But, and this is one of the problems when using passwords for local au-
thentication, this data has to exist on all the hosts a user wishes to log in
on. That, in turn, means that if a single host in the environment is com-
promised, the attacker gets their hands on all users’ password hashes. Once
retrieved, they can then perform so-called o✏ine dictionary attacks on the
password hashes or look them up in widely available rainbow tables, large
pre-computed mappings of common strings to their hashes.
The solutions, or rather, the e↵orts to at least partially address these
issues include the use of a password salt, the previously mentioned small
amount of data added to the user’s password prior to the application of the
hash function, thereby yielding a di↵erent hash on unrelated systems despite
the password being the same and thus defeating simple rainbow table look
ups.
Another approach used frequently is to not make the password hash lo-
cally available on each host and instead rely on an authentication system
where the actual password hashes and additional user information is stored
in a central place and is accessed over the network. The Lightweight Directory
Access Protocol (LDAP) is an example of this approach. However, it should
be noted that the benefits of a central location of this information carries a
certain prize, as well: if the host(s) providing this service becomes unavail-
able, thousands of hosts can become unusable or see debilitating errors. This
problem can of course be defined in a more general statement: as an environ-
ment increases in size, relying on a central service poses an increasing risk of
CHAPTER 6. OF USERS AND GROUPS 183
It is common best practice to disable logins from root over the network7 ,
requiring users to first log in with their usual account, and then to use the
su(1) or sudo(8) utility to perform certain actions with elevated privileges.
Since this tool logs all invocations, we nicely solve the problem of the missing
audit trail; in addition, we gain much finer grained control of what access is
given to which users.
Note, however, that this solution is no panacea: it is easy to fall into a
false sense of security when restricting superuser privileges to a few explicit
commands while forgetting that many of these commands allow a skilled user
to invoke or otherwise trick the system into executing other, non-sanctioned
commands.8 As a general rule of thumb, you should consider the use of
sudo(8) primarily for its audit-trail capabilities and only grant its use to
trusted users.
Secondly, this approach only works on actual server operating systems.
Networking equipment, such as switches, routers, or load balancers, where
the TACACS+ and RADIUS remote authentication protocols allow well-defined
control of remote access do, for the most part, still follow an all-or-nothing
access model locally. The access credentials for the privileged accounts on
these devices (as example might be the “enable” password, used to enter
privileged mode on a router or switch) need to be managed and shared with
the same care that a root password would be.
6.5 Summary
Even though taken for granted nowadays, the nature of a multi-user system
has had from the beginning a number of important implications for overall
system security and operational procedures. The impact of these implications
grows near exponentially as your environment scales up, which is why we
make a point of identifying them explicitly in this chapter.
Users fall into a number of well-defined categories, or types of users. In
particular, we distinguish for good reasons between user accounts used by ac-
7
It is also possible to completely disable the root account, though that may have
implications on your ability to recover the system without physical access in the case of a
severe failure.
8
Most Unix editors, for example, allow a user to invoke a shell; dynamically linked
executables can be tricked into loading custom libraries; the possibilities to exploit access
to a small number of tools running with superuser privileges are too numerous to account
for.
CHAPTER 6. OF USERS AND GROUPS 185
tual humans and so-called system accounts. Di↵erent users (of either kind)
have at times conflicting requirements and impose very specific trust models
on the environment. Access privileges need to be defined and enforced, and
authentication methods need to be considered. We briefly mentioned pass-
words as the most common form of authentication and noted a few of the
problems associated with them; we also covered some of the implications of
sharing root access with your peers.
More generally speaking, though, we looked at what it means for a system
to support multiple users. System administrators with experience managing
deployments in diverse environments are able to recognize and apply these
general rules:
• All users are equal. We need to be able to accomodate di↵erent use
cases and equally enable many di↵erent types of requirements. All
groups of users should be treated with the same professionalism and
their needs appropriately addressed.
• Some users are more equal than others. While all users’ needs should be
addressed, there are, in any system, some users who have more specific
requirements; who need certain elevated privileges; whose computing
demands exceed those of others.
• All users are to be given precisely the access rights they need, but no
more. The principle of least privilege needs to be rigorously applied, as
any one account may become compromised, and the possible damage
deriving from this scenario needs to be limited as much as possible.
• Trust does not scale. When building your infrastructure, remember
that while you may trust all users in your organization today, you
will eventually grow to a size where this no longer holds. It is near
impossible to later on put in place restrictions on users’ privileges,
just as it is to anticiapate the possibly sudden departure of trusted
employees.
• You will always face tradeo↵s. No matter which authentication mecha-
nism you choose, there are downsides. Eliminating single points of fail-
ure may increase your infrastucture’s complexity or increase the risk
of exposure of confidential information. (This holds for many other
aspects of system administration, too, but the impact may be most
obvious when it comes to authentication of users.)
CHAPTER 6. OF USERS AND GROUPS 186
technologies, the overall headache of managing local user accounts may well
be a thing of the past: systems are defined in a descriptive way and spun up or
torn apart as needed. Nevertheless, as experienced system administrators,
we are well aware that new headaches may well lie hidden here, and the
concept of authenticated access by multiple users (for humans and services
alike) continue to apply.
Thus, the burden of identifying the proper access model, however, remains
with the system administrators. Let’s make sure that we understand the
implications of multi-user access on all of our systems as we do!
Problems and Exercises
Problems
1. Review the passwd(5) manual page and make sure you understand
what each field is used for. Is this password database used on the
systems you have access to, or is authentication done by way of a central
system, for example via LDAP? If so, what additional information can
you find in this system?
2. Review the accounts present on your systems. How many of these are
system accounts, and how many are user accounts? What di↵erent
types of users can you identify? Are there any role accounts?
4. Identify whether or not sudo(1) is used on the systems you have access
to. Can you find out which users have which privileges? Which, if any,
commands can you think of that might be dangerous to allow untrusted
users to invoke? Try to think of non-obvious ways to circumvent the
given restrictions.
6. Consider some of the online services you use. What types of authenti-
cation do they require? Which o↵er multi-factor authentication? What
kinds of factors do they use?
188
CHAPTER 6. OF USERS AND GROUPS 189
7. Search the Internet for a list of the most popular passwords in use (such
as, not surprisingly, “password”).
(a) Generate hashes for each password using the following digest al-
gorithms: DES (as used by the Unix crypt(3) family), MD5 and
SHA1. Can you find the resulting strings in any rainbow tables
on the Internet?
(b) Repeat the previous exercise, but add a salt to the password.
What do you notice about the results?
Bibliography
[1] Æleen Frisch, Essential System Administration, O’Reilly Media, 2002
[3] Evi Nemeth, Garth Snyder, Trent R. Hein, Ben Whaley UNIX and Linux
System Administration Handbook, 4th Edition, Prentice Hall, 2010