我试过这个:
d-i preseed/late_command string mkdir -p /target/root/.ssh
d-i preseed/late_command string cp /cdrom/id_rsa.pub /target/root/.ssh/authorized_keys
d-i preseed/late_command string chmod -R go-rwx /target/root/.ssh
Run Code Online (Sandbox Code Playgroud)
(我使用的是 USB 安装程序,并将 id_rsa.pub 放在 USB 驱动器的根目录中。)
未创建 /root/.ssh 目录并且安装程序抱怨 chmod 命令失败(如果该目录不存在也不足为奇)。