Users who are Domain Admins who also have root access must first sudo su - <user>.adm
then they can sudo su - root
Conceptually I think that what you should want and need to achieve is:
All administrators have two personal accounts:
- a "regular" user account
- an administrator account
To gain full administrator rights on a Linux server:
the admin first needs to log in with their regular user account <user>
once logged on the server they escalate their privileges by logging into their personal administrator account <user>.adm
sudo su - <user>.adm
requests the password for the <user>
account, and then, with root privileges, substitutes the user to <user>.adm
.
- ^^^ That is the wrong approach IMHO
You should want your admins to use su - <user>.adm
That means your admin will be required to enter to their password for the <user>.adm
account (rather than the password for the <user>
account) to log in as <user>.adm
.
- Then, as long as your administrators don't have the same password on their adm account as on their regular account, a compromised password won't be sufficient to become root on all your servers. WIN!
- Additionally there is no
sudo
policy required for their regular user account <user>
. WIN!
Once logged in with a personal administrator account that should then allow them to perform all actions that require root
privileges.
That requires setting up a sudo
policy. There's more than enough information about that.
My preference is using the #includedir /etc/sudoers.d
mechanism included in most modern /etc/sudoers
policies (the #
there is not a comment!) and drop a file (that does not include a .
in the file name) and set up policies that way.
One option is to have one policy for hbruijn.adm
personally i.e. /etc/sudoers.d/hbruijn_adm
:
# /etc/sudoers.d/hbruijn_adm
# sudo policy that allow HBruijn's admin account to perform all
# as any user, without prompting for a password
hbruijn.adm ALL = NOPASSWD: ALL
Alternatively when you have all adm accounts that are allowed to gain full root privileges on Linux systems belong to specific group, set up a group based policy.
Implied is that you additionally prevent that your administrators can log in directly to their adm account.
That can be, for example for SSH remote access be achieved by using a DenyUsers
directive in the servers /etc/ssh/sshd_config
to prevent a specific user, or users matching a pattern, from logging on:
# /etc/ssh/sshd_config
#here go defaults for all connections/users
PasswordAuthentication no
PubkeyAuthentication no
...
DenyUsers *.adm
Alternatively use the similar DenyGroups
to set up a group based policy.