Shuting down a Windows system from a Linux one

We want that our NUT sends a shutdown order when there is not suply and the battery goes down. But it could be useful too to shut down a Cybertheque computers, computer classroom, ….

For this we must install a SSH server in Negro (WinXP). And generate a simetric RSA key for connecting automatically and secure.

We will install freeSSHd (, it is a free ssh server for windows, based on OpenSSH.

  • We will install as a service in order to start when the system boots.
  • Create an ups user who login with Public Key:

In the server upsd machine create the keys and their permissions (read and write only the root) for better security:

elite:~# ssh-keygen -t rsa -q -f /etc/nut/rsa_ups
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
elite:~# chmod 600 /etc/nut/rsa_up*

Copy the public file ( to C:\Archivos de programa\freeSSHd\:

Renaming with the user name: C:\Archivos de programa\freeSSHd\ups

Now Windows PC must accept tothe command (using the private key):

ssh -i /etc/nut/rsa_ups “shutdown -s -f -t 60″

In our NUT we will do:

  • Create the script with shutdown orders
# Shutting down the desctop computer (if it will be up)

ssh -i /etc/nut/rsa_ups “shutdown -s –f”

# Shutting down the server

/sbin/shutdown -h +0
  • Change the permissions, to execute the script:
chmod 744 /etc/nut/*.sh

Leave a Reply

Your email address will not be published. Required fields are marked *