Luks,ssh 解锁,奇怪的行为,无效的authorized_keys 文件

tob*_*ora 5 ssh debian initramfs dropbear

我不知道为什么,但我无法在我的 debian 稳定版上按照这些说明进行操作。安装 dropbear 和 busybox 后,我尝试运行initramfs -u. 我在这里收到一个奇怪的警告:

# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.9.0-4-amd64
dropbear: WARNING: Invalid authorized_keys file, remote unlocking of cryptroot via SSH won't work!
Run Code Online (Sandbox Code Playgroud)

然后,我尝试查看文件/etc/initramfs-tools/root/.ssh/id_rsa,但rootinitramfs 文件夹中没有文件夹。我也试着跑

dropbearkey -t dss -f /etc/initramfs-tools/etc/dropbear/dropbear_dss_host_key
Run Code Online (Sandbox Code Playgroud)

但是没有文件夹/etc/initramfs-tools/etc/,所以这个命令也失败了。当然,我可以创建这些文件夹,但恐怕这种奇怪的行为并非来自更深层次的错误。如果有帮助,这里是 initramfs 文件夹的内容:

me@server:/etc/initramfs-tools# ls
conf.d  hooks  initramfs.conf  modules  scripts  update-initramfs.conf
Run Code Online (Sandbox Code Playgroud)

谢谢!

tob*_*ora 6

感谢#debian 上的一些帮助,我终于找到了解决方案。在最近的 debian 上,程序似乎完全不同。这是新的:

首先确保dropbeardropbear-initramfs已安装

sudo apt install busybox dropbear*
Run Code Online (Sandbox Code Playgroud)

然后~/.ssh/id_rsa.pub在文件中添加您的公钥(大部分时间)/etc/dropbear-initramfs/authorized_keys

然后更新initramfs以考虑更改::update-initramfs -u

就这样!

请注意,如果你想避免有之间的键之间的冲突dropbearopenssh(他们共享同一个IP,但使用不同的密钥),你可以把它放到你的客户端~/.ssh/config类似的东西:

Host myserver_luks_unlock
     User root
     Hostname <myserver>
     # The next line is useful to avoid ssh conflict with IP
     HostKeyAlias <myserver>_luks_unlock
     Port 22
     PreferredAuthentications publickey
     IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

然后,您只需使用以下方法连接:

ssh myserver_luks_unlock
Run Code Online (Sandbox Code Playgroud)

一旦收到提示,请按照 busybox 文本的建议键入:

cryptroot-unlock
Run Code Online (Sandbox Code Playgroud)

享受!