Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate ssh host keys on first boot #140

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Generate SSH host keys on first boot
ConditionPathExistsGlob=!/etc/ssh/ssh_host_*_key

[Service]
Type=oneshot
ExecStart=/usr/sbin/dpkg-reconfigure -f noninteractive openssh-server

[Install]
RequiredBy=multi-user.target
4 changes: 4 additions & 0 deletions scripts/build-debian
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ echo "kernel-url,${KERNEL_URL}\n" >> /tmp/versions.csv
/usr/bin/systemctl enable systemd-networkd.service
/usr/bin/systemctl enable systemd-resolved.service
/usr/bin/systemctl enable systemd-timesyncd.service
/usr/bin/systemctl enable generate-ssh-host-keys.service
/bin/rm -f /var/log/*.log
/bin/echo "root:${PASSWORD}" | /usr/sbin/chpasswd
/bin/sed -i "s/#*\s*PermitRootLogin .*/PermitRootLogin yes/" /etc/ssh/sshd_config
Expand All @@ -180,6 +181,9 @@ EOF
# Remove ARM emulation stuff again
rm -v debian/usr/bin/qemu-*-static || :

# Remove ssh host keys, they will be generated on first boot by generate-ssh-host-keys.service
rm -v debian/etc/ssh/ssh_host_*_key* || :

cp -rv --preserve=mode ../2nd-stage-files/post-2nd-stage-files/* debian

# Set hostname
Expand Down
Loading