# Ubuntu – How to disable shutdown or reboot in 14.04 when users are connected via SSH

14.04shutdownssh

I've a group of Ubuntu Trusty desktop PCs in my office, and usually I ssh to them and install updates remotely from the command line. Unfortunately, sometimes local users decide to shutdown those PCs, breaking the update process.

I'd like to prevent those users to shutdown, reboot or suspend their PCs when there's an SSH session active. How can I do it?

I've tried molly-guard, but doesn't prevent GUI users from shutting down the system (it doesn't seem to affect GUI users).
I've seen also this question, but didn't understand if it's applicable also to Ubuntu 14.04 LTS or not (and I'm not sure how to apply it):
disable shutdown/suspend if there is other user logged in via ssh

This could be done using a PolKit policy, if you have admin privileges.

Create a .pkla file in /etc/polkit-1/localauthority/50-local.d (say disable-shutdown.pkla), containing:

[Disable Shutdown, etc.]
Identity=unix-user:*

The -multiple-sessions part is for when multiple users are logged in - there are similar actions without that suffix. This disables these actions from the GUI, as far as I can tell.