[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Turning Linux Server Off remotely

Posted on 2006-11-02
Medium Priority
Last Modified: 2010-04-20
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.
Question by:regisdaniel
  • 2
LVL 43

Accepted Solution

ravenpl earned 672 total points
ID: 17858317
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.
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 664 total points
ID: 17863316

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.



Assisted Solution

paradoxengine earned 664 total points
ID: 17877862
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 ;)
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 17878134
>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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question