ガイド

在VPS上使用远程解锁实现全盘加密

进阶30分で読めます更新日 2026年6月11日
短い回答

LUKS2配合initramfs中的dropbear SSH守护进程,允许你加密根文件系统并在每次启动时远程提供密码短语。提供商永远不会持有密钥,因此断电的磁盘是密文。它不保护免受受损的虚拟机管理程序的影响,并且没有提供商能够诚实地声称其他情况。

01 准确理解这保护了什么

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 安装到加密的根分区

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 将dropbear添加到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 配置启动网络

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 每次重新启动后解锁

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

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

よくある質問

如果服务器在我睡觉时重新启动会发生什么?

它会等待解锁提示。这就是权衡:无人值守的重启是不可能的,这正是使密钥真正属于你的原因。

OnionVPS能解锁我的磁盘吗?

いいえ。私たちはパスフレーズを保持せず、復旧手段もありません。紛失した場合、データは失われます。