Hi,
I am a sysadmin. During long weekends i need to turn off all machines in my lab. Is it possible to shutdown systems using ip address without using ssh.
i read somewhere that shutdown -m "IPADDR" may work. However it seems its a windows specific command.
So my question is how do i remotely shutdown all machine in my LAN using their IP address.
How do i write that script? Writing a script that ssh to each system will be very tedious as i ll have to first create public key pair for around 100 systems. Is there a easier/simpler way to do this?
Their solutions were "push" solutions. You could do a "pull" solution: Write a cronjob to run every minute (or 15 minutes, or whatever); it uses curl to check a web page on your server; if the file exists, the cron job initiates a local shutdown.
if curl -s -i -I http://my.server.ip:port/power-off-`date +%F` | head -1 | grep " 200 OK" >/dev/null ; then
shutdown -h now
fi
On the server, simply run a web server and point the document root somewhere you can write to, and when you want the systems to shut down, simply cd into the web server's document root directory and do:
touch power-off-`date +%F`
The date makes sure the systems dont power off at startup the following day.
If you want to make it secure, generate a self-signed SSL key and distribute the cert to all the hosts.
you should look into using tools like capistrano and puppet to do these tasks. you don't even need keys with capistrano, though it does make things easier.
there are similar tools out there, like func, and mcollective.