firstboot: fix ssh service start issue at first booting

The SSH service fails at first boot due to missing host keys in /etc/ssh
even though new host keys are generated using 'ssh-keygen -A' since the
service keeps restart too quickly.

Therefore new approach is to disable the ssh service when building an
image, enable and start it after new host keys are generated in the
first boot script.

Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: Idee71e55017e72ec693ddf5e829c27da6343f031
This commit is contained in:
Dongjin Kim
2022-05-06 01:36:12 +09:00
parent ff0f20544f
commit 80936afe3a
2 changed files with 5 additions and 1 deletions

View File

@@ -26,3 +26,5 @@ __EOF
systemctl enable firstboot.service
systemctl disable ondemand
systemctl disable ssh

View File

@@ -24,6 +24,8 @@ resize2fs ${rootdev}
rm -f /etc/ssh/ssh_host* && ssh-keygen -A
sed -i "s/PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config
service ssh restart
systemctl enable ssh
systemctl restart ssh
exit 0