My previous laptop is in really poor physical condition, so my plan is to leave it at home as a scraping server (accessed by ssh). How would I remotely turn it off/on? (or do anything else like sleep/hibernate)


Use "Wake-on-LAN" (WOL) IF you have a device in front of it that supports it (e.g. a Linksys WRT54GL with Tomato or DD-WRT). Keep in mind that your laptop also has to support this from the BIOS! If not: use a clock-timer to turn it on might be a work-around...

I used it like this on such a device: Wake-on-LAN (tutorial). Again: if you don't have such a device I would use a clock-timer. ;-)

You can turn the system off through SSH and as root do

shutdown -h now

Shutdown part: this is easy as you can shutdown the machine by issuing a

shutdown -h now

in SSH. You have to launch this as root but giving root SSH access is really really bad practice. You should disable the root access and use sudo or su to launch the command.

Wake up part: you didn't mention if this server should be turned on only by machines in the LAN or if you want to turn it on from the Internet; in the first case it's simple, in the second you'll have troubles if your router doesn't support static routes. WOL is absolutely not supported by WiFi network cards.

  • WOL (Wake on LAN)
    • Enter the BIOS of your server machine and enable the wake on lan/wake on network feature. Normally laptop BIOSes have no settings other than on/off for this feature.
    • Boot your Ubuntu and run "sudo ethtool -s eth0 wol g" assuming eth0 is your network card. This command is for being sure that your network card will turn on your machine only on magic packets.
    • run also "sudo ifconfig" and annotate the MAC address of the network card as it is required later to wake the PC.
    • Shutdown the server machine as it is ready to be woken up.
    • Find a program on your client machine (the one that wakes up the server) that is able to forge the famous magic packet and install it. "wakeonlan" is a good choice as it is right also for the WOW.
    • Learn how to use it: normally you're asked for the server MAC address and nothing else as in LAN the frame will be broadcasted.
  • Wake on WAN (WOW)
    • Do all the steps on the WOL.
    • Check in the web interface of your router if you can assign a MAC Address to a static IP (static routes). If your router doesn't support it (most of the domestic routers I have seen don't) you can't wake your server from the Internet.
    • If you're lucky and have static routes: assign the server mac address to a static IP. Then go to the server and set that IP the way you prefer (via console or gui, indifferent).
    • "Open a port" on the router, telling it that a UDP port (you choose the number) will be redirected to the local server IP.
    • Now with the above program and your external IP address you should be able to wake up your server really remotely.
  • Thanks for the sudo ethtool -s eth0 wol g! For some reason it seems wol was disabled by default and it didn't work until I ran this command. – Djizeus May 28 '16 at 15:17

You can use Wake-on-LAN.

Wake-on-LAN enables users to turn on a computer across a network from another network device. It can be very useful in situations where computers are not all next to each other or there are a lot of machines. WoL works by sending a packet of data called a Magic Packetâ„¢ to the target machine. When the packet is received, the target machine's network device (Network Interface Controller or NIC) wakes-up the rest of the machine.

Ubuntu does support it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.