指南

Full-disk encryption on a VPS with remote unlock

高级阅读时间 30 分钟更新时间 2026年6月11日
简短回答

LUKS2 配合 initramfs 中的 dropbear SSH 守护进程,可让你加密根文件系统,并在每次启动时远程输入口令。提供商从不持有密钥,因此关机状态的磁盘就是密文。它无法防御被入侵的虚拟机监视器,任何提供商若声称可以,都是不诚实的。

01 Understand exactly what this protects

Protects against: physical seizure of a powered-off disk, decommissioned hardware, a datacentre incident, a technician with physical access. Does not protect against: a compromised running hypervisor, or a compromise of the running instance. The key is in memory while the machine runs.

02 Install to an encrypted root

On the Bastion line this is preconfigured. On any other instance, boot the distribution installer through the out-of-band console and choose an encrypted LVM layout.

03 Add dropbear to the initramfs

This is what lets you supply the passphrase over SSH before the root filesystem is mounted.

apt install -y dropbear-initramfs cryptsetup-initramfs
echo 'DROPBEAR_OPTIONS="-p 2222 -s -j -k"' >> /etc/dropbear/initramfs/dropbear.conf
cat ~/.ssh/id_ed25519.pub > /etc/dropbear/initramfs/authorized_keys
update-initramfs -u -k all

04 Configure the boot network

The initramfs has no DHCP client by default; give it a static configuration matching your instance.

# /etc/initramfs-tools/initramfs.conf
IP=203.0.113.10::203.0.113.1:255.255.255.0::eth0:off

05 Unlock after each reboot

Connect on the initramfs port and supply the passphrase. The boot then continues normally.

ssh -p 2222 [email protected]
# then: cryptroot-unlock

常见问题

What happens if the server reboots while I am asleep?

它会停留在解锁提示符处。这就是代价:无法无人值守重启——而这恰恰是密钥真正属于你的原因。

Can OnionVPS unlock my disk?

不。我们从不持有口令,也没有任何恢复机制。如果你丢失了它,数据就没了。