Within this environment, a user named 'user' has the ability to use sudo, but because of how I have the networking and stuff behind the scenes set up, I don't want the user to be able to access tools like iptables
, iproute2
, net-tools
, etc. There are a plethora of others that I would like to disallow (like mount
and sudo su
) but I obviously can't know all of them. I would like to allow the user to use all the basic commands like ls
, cd
, pwd
, etc.
It's fine if I have to list all the allowed commands since this is a more finite list than the ones that I would like to disallow.
Currently, I am going with the blacklist approach and listing all of the commands that I don't want, but it seems like the least secure and dumbest way to do so. This is how the current sudoers file looks like:
Cmnd_Alias APTNETTOOLS = /usr/bin/apt-get install iptables, /usr/bin/apt-get install iproute2, /usr/bin/apt-get install libghc-iproute-dev, /usr/bin/apt-get install net-tools, /usr/bin/apt install iptables, /usr/bin/apt install iproute2, /usr/bin/apt install libghc-iproute-dev, /usr/bin/apt install net-tools
Cmnd_Alias RESTRICTEDCMNDS = /usr/bin/ip, /usr/sbin/route, /usr/sbin/iptables, /usr/sbin/arp, /usr/sbin/ip, /usr/bin/networkctl
Cmnd_Alias ELEVCMNDS = /usr/sbin/visudo, /usr/bin/su
# See sudoers(5) for more information on "#include" directives:
user ALL=ALL, !APTNETTOOLS, !ELEVCMNDS, !RESTRICTEDCMNDS