Skip to content

Unlock LUKS via SSH

Auto script

curl -OL hacker.st/ssh-luks.tar.gz

Or clone the repository

git clone https://github.com/uvns/archlinux-initrd-ssh-cryptsetup.git
cd archlinux-initrd-ssh-cryptsetup

Instal ssh-cryptsetup

makepkg -sri

Generate dropbear key

dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key

Add public key to initrd.authorized_keys

vi /etc/dropbear/initrd.authorized_keys

Add network devices and hooks to /etc/mkinitcpio.conf

vi /etc/mkinitcpio.conf
MODULES=(e1000 e1000e virtio_net vmxnet3)
HOOKS=(base udev autodetect microcode modconf kms keyboard keymap consolefont block ssh-cryptsetup sd-encrypt lvm2 filesystems fsck)

Setup network and disable systemd to unlock LUKS

vi /etc/default/grub
GRUB_CMDLINE_LINUX="ip=:::::eth0:dhcp rd.luks=0"

Edit /etc/crypttab

vi /etc/crypttab

Crypttab file

cryptroot      UUID=xxxxxxxxxxxxxxxxxxxxxx    none                    luks

Finalize

mkinitcpio -p linux-lts
grub-mkconfig -o /boot/grub/grub.cfg