System Shutdown

Copy the root's key file to the ssh directory of your main user:

# cp /root/.ssh/id_rsa /home/user/.ssh/id_rsa_root
# chown user:user /home/user/.ssh/id_rsa_root
# chmod 600 /home/user/.ssh/id_rsa_root

you can now shut down the virtual machine with the following command:

$ ssh root@machine -i /home/user/.ssh/id_rsa_root "shutdown -h now"

To shutdown the physical server as user or from the desktop, do the following:

# cp /sbin/shutdown /home/bco/batch
# chmod 755 /home/user/batch/shutdown
# chmod +s /home/user/batch/shutdown

This is better than changing the permissions of the original shutdown file, as this would allow any user on the sytem to issue the shutdown command. For whatever reasons, giving access through visudo or by establishing a group for shutdown does not work on Debian Wheezy.

Make sure that “batch” is accessible by user only. You can now shut down the physical server with:

$ /home/user/batch/shutdown -h now