Skip to content

LUKS with Dropbear

LUKS (Linux Unified Key Setup) provides full-disk encryption. Dropbear is a lightweight SSH server that can run in the initrd to allow remote unlocking.

The setup works as follows:

  1. Server boots with encrypted root filesystem
  2. initrd loads with dropbear SSH server
  3. You connect via SSH and enter the LUKS passphrase
  4. Disk unlocks and boot continues normally
  • Debian/Ubuntu (other distros have similar packages)
  • LUKS-encrypted root partition
  • Static IP or DHCP during boot
Terminal window
sudo apt install dropbear-initramfs cryptsetup-initramfs

Edit /etc/dropbear/initramfs/dropbear.conf:

Terminal window
# Use a non-standard port to avoid conflicts with main SSH
DROPBEAR_OPTIONS="-p 2222 -s -j -k"

Options explained:

  • -p 2222 - Listen on port 2222
  • -s - Disable password login (key only)
  • -j - Disable local port forwarding
  • -k - Disable remote port forwarding
Terminal window
# Add your articwake public key
cat articwake-key.pub >> /etc/dropbear/initramfs/authorized_keys

Edit /etc/initramfs-tools/initramfs.conf:

Terminal window
# For DHCP
IP=dhcp
# Or for static IP
# IP=192.168.1.100::192.168.1.1:255.255.255.0:hostname:eth0:off

Format for static: IP=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

Terminal window
sudo update-initramfs -u
Terminal window
# Connect to dropbear
ssh -p 2222 -i articwake-key root@server-ip
# The unlock prompt appears automatically
# Enter your LUKS passphrase

The cryptsetup-askpass utility in initrd:

  1. Waits for input on stdin
  2. Passes it to cryptsetup to unlock the disk
  3. Signals the boot process to continue

This is what articwake connects to and sends the passphrase.

If you have multiple LUKS volumes, you may need to unlock them all:

Terminal window
# Check which devices need unlocking
cat /etc/crypttab

The cryptsetup-askpass utility handles this automatically if configured correctly.

Verify the initrd contains dropbear:

Terminal window
lsinitramfs /boot/initrd.img-$(uname -r) | grep dropbear

Should show dropbear binaries and config.

  1. Reboot the server
  2. Wait for it to reach initrd (check DHCP leases or known IP)
  3. SSH in:
    Terminal window
    ssh -p 2222 -i articwake-key root@server-ip
  4. Enter passphrase when prompted
  5. Server should continue booting
  1. Network not up: Check if IP is assigned

    • Verify /etc/initramfs-tools/initramfs.conf network config
    • Rebuild initramfs: update-initramfs -u
  2. Wrong port: Verify dropbear port in config

    Terminal window
    grep DROPBEAR /etc/dropbear/initramfs/dropbear.conf
  3. Firewall: initrd usually has no firewall, but check your network

  1. Verify public key is in /etc/dropbear/initramfs/authorized_keys
  2. Rebuild initramfs after adding key
  3. Dropbear uses its own key format - Ed25519 works but ensure correct format
  1. Test locally first with cryptsetup open
  2. Verify correct LUKS slot has your passphrase
  3. Check keyboard layout issues (initrd may use US layout)

Check /etc/crypttab has correct device and options:

root_crypt UUID=xxxx-xxxx-xxxx none luks
  • Use a dedicated SSH key for initrd unlock
  • The initrd SSH key is separate from your main system
  • Dropbear regenerates host keys on each boot
  • articwake is configured to accept any host key for this reason