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
(saydisable-shutdown.pkla
), containing: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.Note that this method only blocks reboot, etc., commands issued from GUI. To block reboot, etc., commands from command line, one may use molly-guard - as explained in Disabling shutdown command for all users, even root - consequences?