shutdown account

shutdown account

by Joseph Kwan

Purpose

This note documents how to configure a shutdown account for a system to provide an easy way for a system to be shutdown just by entering the password for the account on a login. I do this for several systems I have that are integrated in hardware racks and the systems are treated more as instruments rather than as a computer. sudo is use in combination with the login script. The NOPASSWD sudo configuration is used to allow the shutdown command to run as root, without prompting for the user password.

Configuration

Configuration just involves setting up the user account (non-privileged), configuring sudo to allow the account to run shutdown and then setting up the account start up file so the sudo shutdown command is run upon login. For the user account, I'm using the account name shutdown as the login account.

/etc/passwd

shutdown:x:17991:60001:shutdown account:/var/sys/shutdown:/usr/bin/bash

/etc/shadow

shutdown:_encrypted password_:13942::::::

sudoers

# define a command alias with the path for shutdown
Cmnd_Alias      SHUTDOWN=/usr/sbin/shutdown

# shutdown account capabilities definition
# the "NOPASSWD" option allows the command to run
# without requiring the user's password
shutdown _hostname_=NOPASSWD:SHUTDOWN

The first field is the account name, shutdown in this configuration. Then the host name(s) and the sudo capabilities authorized. If you have multiple hosts you can define a host alias and use that alias.

.bash_login/.bashrc

# .bashrc/.bash_login (symlink to each other)
sudo /usr/sbin/shutdown -y -g0 -i5

Note: this assumes sudo is in the path. The -i5 shutdown option powers down a Solaris machine.

  • set a password for the shutdown account, then test by logging into it (either on the console or remotely logging in). The machine should shutdown and power off (in the case above).
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact