Sshd does not start after install

This has never happened, and then, suddenly, again ... When installing Ubuntu server on VirtualBox at first everything went fine, but after installing sshd the service did not start

The output of journalctl -xe did not show anything specific

Nov 18 10:04:14 ub2004 systemd[1]: ssh.service: Start request repeated too quickly.

Nov 18 10:04:14 ub2004 systemd[1]: ssh.service: Failed with result 'exit-code'.

-- Subject: Unit failed

-- Defined-By: systemd

-- Support:


-- The unit ssh.service has entered the 'failed' state with result 'exit-code'.

Nov 18 10:04:14 ub2004 systemd[1]: Failed to start OpenBSD Secure Shell server.

-- Subject: A start job for unit ssh.service has failed

-- Defined-By: systemd

-- Support:


But when manually starting sshd, a problem message was displayed

sshd -t

sshd: no hostkeys available – exiting

I don't know why the host keys were not generated during installation. But this is fixed very simply

ssh-keygen -A



service ssh restart

and the service started without errors