Skip to content

My Workstation Sleeps Until I Need It: Wake-on-LAN for an AI Homelab

How I keep a 128 GB AI workstation asleep most of the day and wake it in seconds from an always-on home server: SSH aliases, Wake-on-LAN, suspend instead of shutdown, and a RustDesk surprise after the first reboot.

5 min read
on this page7 sections

In Part 0 I described my setup: a MacBook Air as the remote control, a big workstation where AI agents run, and a small always-on server that archives everything.

The whole design depends on one thing: the workstation can sleep, and I can wake it from anywhere in seconds. If waking it is unreliable, I’d just leave it on, and then the setup has no point.

This post covers that layer. Both machines run Ubuntu 24.04:

  • workstation: the big one, wired to the router
  • homeserver: the small always-on box that sends the wake-up signal

Step 1: SSH from the home server to the workstation

Everything else builds on the home server being able to reach the workstation without a password.

On the homeserver:

ssh-keygen -t ed25519 -N "" -C "homeserver" -f ~/.ssh/id_ed25519
ssh-copy-id me@192.168.1.50

I used no passphrase (-N "") on purpose. Scripts on this box run unattended, and it never leaves my house. On my laptop I’d make a different call.

Then I gave the workstation a short name in ~/.ssh/config:

Host workstation
    HostName 192.168.1.50
    User me
    IdentityFile ~/.ssh/id_ed25519

Now ssh workstation hostname works without a prompt.

Don’t skip this: add a DHCP reservation for the workstation in your router. Wake-on-LAN, SSH and your config all assume the IP never changes. Mine changed once before I did this.

Step 2: Check that the network card supports Wake-on-LAN

Wake-on-LAN works like this: the network card stays powered while the computer is asleep or off, and listens for a “magic packet”, a special broadcast frame that contains its MAC address. When it sees one, it wakes the machine.

It only works over Ethernet. Wi-Fi WoL exists on paper, but in practice it isn’t usable.

On the workstation, find the interface and its MAC:

ip -br link
# enp6s0   UP   aa:bb:cc:dd:ee:ff  <BROADCAST,MULTICAST,UP,LOWER_UP>

Then ask the card what it supports:

sudo ethtool enp6s0 | grep -i wake-on
#   Supports Wake-on: pumbg
#   Wake-on: g

The letter that matters is g, the magic packet. Supports Wake-on should include it. Wake-on: g means it’s enabled right now, and d means disabled.

Mine was already g. I made it permanent anyway, because some drivers quietly reset to d after a reboot or a kernel update, and then WoL “randomly” stops working. On a desktop Ubuntu that uses NetworkManager:

sudo nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
nmcli -g 802-3-ethernet.wake-on-lan connection show "Wired connection 1"
# magic

Now NetworkManager re-applies the setting every time the connection comes up.

BIOS: waking from a full shutdown also needs the BIOS to keep the network card powered. Look for “Wake on LAN” or “Power On By PCI-E” (enable it), and “ErP” or “Deep Sleep” (disable it, because it cuts power to the card). On my board the defaults already worked, but this is the first place to look if waking from a shutdown fails.

Step 3: A wake script that waits until the machine is actually ready

Sending the packet is one line. The useful part is knowing when the machine is ready. On the homeserver:

sudo apt install -y wakeonlan

~/bin/wake-workstation:

#!/usr/bin/env bash
MAC="aa:bb:cc:dd:ee:ff"
ok() { ssh -o ConnectTimeout=2 -o BatchMode=yes workstation true 2>/dev/null; }
 
if ok; then echo "Workstation is already up."; exit 0; fi
 
wakeonlan -i 192.168.1.255 "$MAC"
echo "Magic packet sent, waiting for the workstation (up to 3 min)..."
 
for i in $(seq 1 60); do
  if ok; then echo "Workstation is up and reachable."; exit 0; fi
  sleep 3
done
echo "No response. Check the BIOS settings and the cable."; exit 1

A few details:

  • BatchMode=yes makes SSH fail immediately instead of asking for a password. It’s a pure yes/no check: “can I log in right now?”
  • -i 192.168.1.255 sends the packet to the broadcast address of my subnet. The sleeping machine has no IP to talk to, but its card hears broadcasts.
  • The script exits successfully only when SSH works, not when the packet is sent. That’s the moment that matters to me.

Step 4: Suspend, don’t shut down

I almost never shut the workstation down. I suspend it, for three reasons:

  1. Everything stays where I left it: open apps, terminals, containers.
  2. It wakes in 5–15 seconds instead of a minute or more.
  3. WoL from suspend is more reliable, because the network card is already powered.

Suspending a remote machine over SSH has a small trap. If you run ssh workstation sudo systemctl suspend, the machine goes to sleep mid-command and your terminal hangs until the connection times out.

The fix is to schedule the suspend a few seconds out, so SSH can disconnect cleanly first. ~/bin/sleep-workstation:

#!/usr/bin/env bash
echo "Suspending the workstation in 5 seconds..."
ssh -t workstation "sudo systemd-run --on-active=5 systemctl suspend"

systemd-run --on-active=5 creates a one-off timer on the workstation. SSH returns immediately, and five seconds later the machine goes to sleep.

Step 5: Test both cases

I tested two scenarios, and you should too.

Suspend → wake (the everyday case):

~/bin/sleep-workstation
sleep 20
ping -c 3 -W 1 192.168.1.50   # expect: 100% packet loss
~/bin/wake-workstation        # expect: "up and reachable" within seconds

Power off → wake (the power-outage case). If the power goes out while the workstation is suspended, it comes back off, not suspended. If WoL only works from suspend, you find out at the worst possible time.

ssh -t workstation 'sudo poweroff'
sleep 60
~/bin/wake-workstation        # expect: "up and reachable" after 30–90 s

Both worked for me. The second test also gave me a free reboot, which turned up the next problem.

Gotcha: RustDesk and the Wayland login screen

I use RustDesk to reach the workstation’s desktop when I need a GUI. After the power-off test, RustDesk connected and showed:

Login screen using Wayland is not supported

Before the reboot I’d always been logged in, so it never came up. Ubuntu 24.04 uses Wayland by default, and RustDesk can’t capture the Wayland login screen. That’s a deliberate security limitation of Wayland, not a RustDesk bug. For a machine you mostly reach remotely, it’s a dealbreaker.

The fix is to switch the display manager to Xorg:

sudo sed -i 's/^#\s*WaylandEnable=false/WaylandEnable=false/' /etc/gdm3/custom.conf
grep WaylandEnable /etc/gdm3/custom.conf   # must show it WITHOUT the leading #
sudo systemctl restart display-manager

This restarts only the graphical login, not the whole machine. SSH sessions survive. After that, RustDesk shows the login screen normally.

What I have now

  • One command wakes the workstation, and it tells me when it’s ready.
  • One command puts it to sleep, cleanly, with everything still open.
  • It survives power cuts: WoL works from a full shutdown too.
  • I can reach the desktop even after a reboot.

There’s one thing I haven’t solved yet: nothing stops me from suspending the workstation while an agent is in the middle of a job. Containers survive suspend, but an API request in flight doesn’t. I’ll add a guard (systemd-inhibit tied to running agents) later in the series.