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/