On the RHEL 8 and previous it is usual, that the SSH host keys in /etc/ssh
are generated automatically by sshd
service when missing. Usually there should be:
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_host_ed25519_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_rsa_key.pub
Restart of the node or even systemctl restart sshd
should be sufficient.
But as of the minor version RHEL 8.7 this may not work any more and the sshd
crashes complaining about missing host keys in the journal log. Why? How can I solve this?
The
sshd
service by default callssshd-keygen.target
, which checks availability of host keys in/etc/ssh
directory and generates it when missing.However this well known functionality can be blocked by the new version of
cloud-init
. As ofcloud-init-22.1-5.el8.noarch
there is new file:with content:
So when you use the
cloud-init
you have 2 options now:ssh-keygen -A
(see How to change a SSH host key? for more details and options.Simply put the
#
sign beforeConditionPathExists...
Then reload the systemd configuration with
systemctl daemon-reload
. The usual behavior should be working again.