LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   disable shutdown/reboot remotely (https://www.linuxquestions.org/questions/linux-security-4/disable-shutdown-reboot-remotely-616356/)

jessicaK 01-25-2008 03:33 PM

disable shutdown/reboot remotely
 
Hello!

Is there anyway to disable shutdown/reboot/halt etc commands from anyone not locally logged into the server?

michaelsanford 01-25-2008 03:47 PM

As far as I know, no direct way (like a haltrc file that allows you to restrict who can run it).

However, since you need to run shutdown as root (either as root or prefixed with sudo) you CAN change the /etc/sudoers file like so:
Code:

username localhost=/sbin/shutdown
%groupname localhost=/sbin/shutdown

This will allow them to run the specified command(s) only from localhost, and not from a remote machine over ssh. The group name is optional (as is the username), I only included it so you can see how it's used. You can just as easily specify a bunch of individual users, or a group with no individual users.

FYI: If you have a server with multiple users who all can play with the root account directly, though, you should fix that problem first :)

PS Make sure you don't accidentally (especially with a group specification) restrict yourself from restarting the machine remotely!

jessicaK 01-28-2008 07:37 AM

I definately agree, trust me! Its oracle consultants that unfortunately need mostly root access until they have completed the implementation. We just have to make sure that until this is done they don't randomly reboot the server again :)

Thanks for your help and it's exactly what I was looking for!


Quote:

Originally Posted by michaelsanford (Post 3035468)
As far as I know, no direct way (like a haltrc file that allows you to restrict who can run it).

However, since you need to run shutdown as root (either as root or prefixed with sudo) you CAN change the /etc/sudoers file like so:
Code:

username localhost=/sbin/shutdown
%groupname localhost=/sbin/shutdown

This will allow them to run the specified command(s) only from localhost, and not from a remote machine over ssh. The group name is optional (as is the username), I only included it so you can see how it's used. You can just as easily specify a bunch of individual users, or a group with no individual users.

FYI: If you have a server with multiple users who all can play with the root account directly, though, you should fix that problem first :)

PS Make sure you don't accidentally (especially with a group specification) restrict yourself from restarting the machine remotely!


michaelsanford 01-28-2008 03:08 PM

Well, you can restrict almost anything in this way, either whitelist or blacklist, in many different ways. Check out "man sudoers" for more information (the name of the config file itself, rather than the command).

Glad it helped!

Micro420 01-29-2008 11:20 AM

I'm pretty certain that you can also do this by modifying a specific PAM module. But if you can do without touching it, then don't touch it. I've locked myself out of a system before and it's not pretty


All times are GMT -5. The time now is 03:18 AM.