Skip to content

Commit

Permalink
get fresh ssh keys on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Jun 15, 2020
1 parent 51261d5 commit afc35de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ubuntu/helpers/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ cp makedev /etc/apt/preferences.d/makedev
cp locale.conf /etc/locale.conf
cp locale /etc/default/locale

# make sure we get fresh ssh keys on first boot
/bin/rm -f -v /etc/ssh/ssh_host_*_key*
cp regenerate_ssh_host_keys.service /etc/systemd/system
systemctl daemon-reload
systemctl enable regenerate_ssh_host_keys
# Remove the divert that disables services
rm -f /sbin/initctl
dpkg-divert --local --rename --remove /sbin/initctl
Expand Down
11 changes: 11 additions & 0 deletions ubuntu/helpers/regenerate_ssh_host_keys.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Regenerate SSH host keys
Before=ssh.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-keygen -A -v
ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys

[Install]
WantedBy=multi-user.target

0 comments on commit afc35de

Please sign in to comment.