[Bug 1778386] [NEW] If SSH host keys are missing, they should automatically regenerate at boot time

Launchpad Bug Tracker 1778386 at bugs.launchpad.net
Sun Jun 24 13:14:47 UTC 2018


You have been subscribed to a public bug:

When SSH host keys are missing, they should be automatically regenerated
at boot time so SSH functions.  This is particularly useful if cloning
VM's or using a VM template.

I have modified the following using CentOS 7's .service file.

/lib/systemd/system/ssh-keygen.service :

[Unit]
Description=OpenSSH Server Key Generation
ConditionFileNotEmpty=|!/etc/ssh/ssh_host_rsa_key
ConditionFileNotEmpty=|!/etc/ssh/ssh_host_ecdsa_key
ConditionFileNotEmpty=|!/etc/ssh/ssh_host_ed25519_key
PartOf=ssh.service sshd.socket

[Service]
ExecStart=/usr/sbin/dpkg-reconfigure openssh-server
Type=oneshot
RemainAfterExit=yes

And added the following to ssh.service.

/lib/systemd/system/ssh.service :
[Unit]
...
After=network.target ssh-keygen.service
...
Wants=ssh-keygen.service
...

I have tested this and it is working.

** Affects: openssh (Ubuntu)
     Importance: Undecided
         Status: Won't Fix


** Tags: ssh
-- 
If SSH host keys are missing, they should automatically regenerate at boot time
https://bugs.launchpad.net/bugs/1778386
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to openssh in Ubuntu.



More information about the foundations-bugs mailing list