How to add a public ssh key using debian preseed file?
8
votes
2
answers
3720
views
Using debian preseeding, I want to copy a public key to
/root/.ssh/authorized_keys
with correct permissions so that I can use ansible to configure the rest of system.
I already selected openssh-server to be installed by selecting d-i pkgsel/include string openssh-server build-essential
in the preseed file.
Would this late command work?
d-i preseed/late_command string in-target mkdir -p /root/.ssh; \
in-target /bin/sh -c "echo 'ssh-ed25519 AAAAC3NzaC1IAg1wilR9asDXIPwTsvZXasdTXqasdKv0rIqqweAtxGVgup foobar' >> /root/.ssh/authorized_keys"; \
in-target chown -R root:root /root/.ssh/; \
in-target chmod 644 /root/.ssh/authorized_keys; \
in-target chmod 700 /root/.ssh/
Asked by Cruise5
(546 rep)
Oct 5, 2022, 03:06 AM
Last activity: Oct 1, 2024, 08:02 PM
Last activity: Oct 1, 2024, 08:02 PM