thedark Second Lieutenant
Joined: 30 Jul 2005
Posts: 1074
|
Posted: Sun Jul 31, 2005 10:21 am Post subject: Shutdown account to shutdown Linux server |
|
|
1) Setup password for shutdown account:
# passwd shutdown
2) Add access to shutdown –h now via sudo:
# visod
Put any one of following line in your sudo configuration file:
shutdown ALL=/sbin/shutdown –h now
OR
shutdown localhost=/sbin/shutdown –h now
Note that localhost will only allow sudo from local terminal. If you want network based shutdown then make sure you use ALL or IP or Domain name, for complete syntax read man page of sudo.
3) Save and exit to shell prompt
4) Change shutdown shell:
# vi /etc/passwd
Replace existing shell entry (/sbin/shutdown) to
/usr/bin/sudo /sbin/shutdown –h now
Example
From:
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
To
shutdown:x:6:0:shutdown:/sbin:/usr/bin/sudo /sbin/shutdown –h now
5) Save file
6) Test it by login into system with shutdown username and password.
7) Please, note down that sudo will prompt for password. If you wish to get rid of this issue use NOPASS option in sudo configuration file.
Alternatively, you can use sudo only to achieve same effect. This simple hack ensures that ordinary user shutdown system without touching other part of system |
|