Turn on a remote computer

I have a machine that I use to do lot of work. However, I want to avoid having it on 24/7. Hence, sometiems I need to turn it on remotely to start working

Guide

To turn on your computer remotely, you need to be in the same network and then use the protocol "Wake-on-Lan." Read below for a step-by-step guide.

  1. Be in the same network. I recommend having a Raspberry Pi on 24/7, which you can SSH into anytime. Alternatively, you can use a VPN to connect to your network (also via a Raspberry Pi).

  2. SSH into the Raspberry

  3. Create a directory for managing this operation.

# use wake on lan
mkdir remote_on
  1. Find out the MAC address of your computer. You can do it. Then save it in file MAC_ADDR:

# use wake on lan
cd remote_on
echo "..." > MAC_ADDR
  1. If not available, install a client to use Wake-on-Lan. I use etherwake.

  2. Draft a script to do the job

# use wake on lan
MAC_FILE="$(dirname "$0")/MAC_ADDR"
etherwake -i eth0 "$(cat "$MAC_FILE")"
  1. Make the script executable

chmod +x /home/pi/remote_on/script.sh
  1. Add an alias to your .bashrc like:

alias turnon='sudo /home/pi/remote_on/script.sh'

Main reference

Wake on Lan:

Last updated

Was this helpful?