Solved

Turning Linux Server Off remotely

Posted on 2006-11-02
6
296 Views
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.
0
Comment
Question by:regisdaniel
  • 2
6 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 168 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
http://www.nz-honeynet.org/passwordless-ssh.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.
http://www.wlug.org.nz/SudoHowto
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 166 total points
ID: 17863316
Hi,

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:
visudo

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.

Cheers,
K.






0
 
LVL 9

Assisted Solution

by:paradoxengine
paradoxengine earned 166 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 ;)
0
 
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 :
/home/rmtsht/rmtsh
- Ignore the warning - Observe the
Shell changed
message
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now