Dropbear remote crypto unlock via IPv6

2019-12-31 17:04

This post will explain how to set up IPv6 connectivity via a initramfs script to remotely unlock your root partition on a server which uses a technology stack of dropbear (to be included in the intramfs) and cryptsetup via IPv6 and IPv6 only. Unlocking your root partition with this workflow is less secure than using the out-of-band management if you consider unattended hardware access of an attacker to your device as probable.

Version history

  • Initial release
  • 2021-06-12: Add section for IPv6-only
  • 2025-01-01: With Debian 12 (bookworm), the paths of the dropbear initramfs changed from /etc/dropbear-initramfs to /etc/dropbear/initramfs and Thorsten Glaser inspired me to use his scripts for creating a repo initramfs-ipv6. I'm currently working on using a lacp bond for unlocking, stay tuned.

Prerequisites

I am assuming you are successfully using dropbear to remotely unlock your root partition using cryptsetup via legacy-ip (IPv4).

Starting with version 2020.79, dropbear supports ed25519 host and authorized keys. You may then also consider removing the rsa and ecdsa host keys, leaving only ed25519:

rm /etc/dropbear/initramfs/dropbear_ecdsa_host_key
rm /etc/dropbear/initramfs/dropbear_rsa_host_key
update-initramfs -k all -u

Attention: use only dropbearkey for creating host keypairs for dropbear.

For the initramfs-configure-ipv6-script you need to know

  • IPv6 address
  • network device
  • default route (optional if you are connecting from the same network segment)

Setting up IPv6 during initial boot

# cat /etc/initramfs-tools/scripts/local-top/ipv6
#!/bin/sh
PREREQ=""
prereqs()
{
    echo "$PREREQ"
}
case $1 in
    prereqs)
        prereqs
        exit 0
        ;;
esac

ip addr add 2001:db8::/64 dev eth0
ip route add default via fe80::1 dev eth0

Make it executable chmod +x /etc/initramfs-tools/scripts/local-top/ipv6 and regenerate the initramfs for all of your installed kernels update-initramfs -u -k all.

Unlocking an IPv6-only host

Set /etc/initramfs-tools/initramfs.conf to

DEVICE=eth0
IP=:::::eth0:off

and configure IPv6 as described above.

Bonus information for crowded legacy-ip

Sometimes, it is actually possible to use the "network address" of an IPv4 network as regular address. Let us look at 192.168.42.128/29 as an example. Five IP addresses can be used within /29 network: The gateway usually sits at address .129, use .130-.134, and .135 is broadcast. In this scenario, try using the .128. It might just work :)