In centos there is a the directive AUTOCREATE_SERVER_KEYS=YES you can put in the /etc/sysconfig/sshd file to tell sshd to re-create its ssh server keys if the keys are missing.
Is there any such way in Ubuntu server 20.04?
In centos there is a the directive AUTOCREATE_SERVER_KEYS=YES you can put in the /etc/sysconfig/sshd file to tell sshd to re-create its ssh server keys if the keys are missing.
Is there any such way in Ubuntu server 20.04?
I'm not aware of any equivalent setting.
The Ubuntu/Debian method I usually see suggested to generate missing SSH host keys is the command
dpkg-reconfigure openssh-server
Ubuntu systems with cloud-init
by default will use the SSH host-keys module to automatically regenerate host-keys. This module is per-instance, which means it will only run during the first boot.
It might help if you provide the use case for why you need to recreate the SSH host keys.