Skip to main content
Question

Any way to restrict specific commands in Terminal?

  • September 20, 2022
  • 3 replies
  • 2 views

Forum|alt.badge.img+7

Hi there,

I've had a request from our CISO about restricting the following command (and any others in the future):

sudo -s

We still want to allow people to run sudo, but within their own shell, so restricting access to Terminal/iTerm2 is not an option.

What we need to do is still allow people to run sudo commands, but not be able to open a root shell by using sudo -s

Anyone have any ideas?

3 replies

Forum|alt.badge.img+9
  • Contributor
  • 154 replies
  • September 20, 2022

Take a look at Automatically Lockdown/Disable Root access on MacOS

But keep in mind the best way to stay protected is removing admin where possible.  


markanderson
Forum|alt.badge.img+1
  • New Contributor
  • 9 replies
  • September 22, 2022

So the best solution is :
1. Create the restricted shell. ...
2. Modify the target user for the shell as restricted shell.
3. Create a directory under /home/localuser/ , e.g. programs. ...
Now if you check, the user localuser can access all commands which he/she has allowed to execute.


donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • September 25, 2022
markanderson wrote:

So the best solution is :
1. Create the restricted shell. ...
2. Modify the target user for the shell as restricted shell.
3. Create a directory under /home/localuser/ , e.g. programs. ...
Now if you check, the user localuser can access all commands which he/she has allowed to execute.



@markanderson wrote:

So the best solution is :
1. Create the restricted shell. ...
2. Modify the target user for the shell as restricted shell.
3. Create a directory under /home/localuser/ , e.g. programs. ...
Now if you check, the user localuser can access all commands which he/she has allowed to execute.


Didn't know that was a bash option, would love to see an example. #kudogiven


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings