Turning Linux Server Off remotely

Hi experts.

My company purchased a nobreak that have the ability to turn off the computer when the batery charge gets critical. This job is done using the Nobreak's software (Upsilon 2000), that is installed on Windows server.

My enviroment have 6 servers: 1 Windows 2003 Server and 5 SuSE Linux Enterprise Server.
The Nobreak's software have the ability to call an application when it starts the shutdown sequence. So, my ideia is to develop an small aplication that will connect to the Linux Serves and inform them to start a shutdown operation but I have no ideia of how this could be implemented on my Linux servers...

Does anybody have any advice?
Thanks a lot.
Who is Participating?
configure passwordless ssh connection from Your windows box to all linux boxes.
On Windows shutdown call each linux and remotely run /sbin/poweroff

Windows ssh client http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Not You have to run /sbin/poweroff as root user.
Or You could configure new user for that purpose, that allow him to execute /sbin/poweroff with root privs via sudo.
Kerem ERSOYPresidentCommented:

Your software might be able to remotely shutdown other systems. Please consult your product manual.

logon to your remote system that you want to shutdown remotely as root

issue this command:
groupadd shutdown

useradd  -g shutdown rmtsht
passwd rmtsht

(Enter a password for the account or it ill be login disabled)

now issue this command:

and add this line in the file

%shutdown ALL=(root) NOPASSWD: /sbin/shutsys.sh

Save and quit. (don't forget to press enter after the line before saving.)

Edit /sbin/shutsys.sh

enter these lines in it:

#! /bin/sh
/sbin/shutdown -h now

Save and quit. Issue:

chmod 500 /sbin/shutsys.sh

Now edit /home/rmtsht

and add this line at the end:

sudo /sbin/shut.sh

Save and quit.

Now ensure "passwordless-ssh" as ravenpl indicated.

Now when you launch with rmtsht user like that:

C:\path\to\putty -ssh rmtsht@IP_TO_SHUTDOWN

it will shutdown the system.


make sure that the user will only be able to run that command (ssh will allow you to set it running at login instead of /bin/bash or other shells): improved security is always good ;)
Kerem ERSOYPresidentCommented:
>Now edit /home/rmtsht
Ooops sorry the line above must read:

Now edit /home/rmtsht/.bash_profile

if you want t further restrict this user to run only this script.

- change to user home directory.
- create a shell file called rmtsh and add these lines in it:
#! /bin/sh
sudo /sbin/shut.sh

- Save and exit
- chmod 500 rmtsh
- if you created the file as root issue this command too:
  chown rmtsht.shutdown rmtsh
- issue this comand as root:
chsh rmtsht
- after the
New shell [/bin/bash]:
prompt enter the new shell as :
- Ignore the warning - Observe the
Shell changed
if you want you can also
chmod 750 /home/rmtsh

so that only rmtsh and users in shutdown group (read-only) could see the ccontent of this directory.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.