I noticed on some of my Debian Buster installs, SSH times out and then waits until “random: crng init done” happens before restarting and finally allowing remote logins. This can sometimes add an extra 1+ minutes to boot time and can be pretty annoying. So if you’re experiencing a problem with SSH hanging or timing out while you’re server is booting up, then hopefully this quick how-to guide will help you out!
Why does it happen?
I did a bit of Googling and found a Debian bug report for this at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912087 which gives some thoughts on the problem and that it seems to be related to RNG. So if you’re experiencing the issue of SSH waiting on “random: crng init done” before it restarts and completes startup then it’s because of low entropy on your system (especially when it comes to virtual machines/vpses).
You can check the available entropy on your machine by running:
If that shows a number below 300 or so then you’re running low on available entropy.
How to fix it
If you encounter this SSH timeout issue, you can fix it by installing haveged or rng-tools5 (if you have a hardware RNG device). Both of these packages generate entropy so you won’t be running low on entropy and ssh should start like normal during the boot process.
To install haveged on your Debian or Ubuntu server, just run this command:
sudo apt install haveged
and it should automatically start and already be generating entropy after install. You can check the status of it by running the following command:
sudo systemctl status haveged
Now when you run the command:
you should have a lot more entropy available! Try rebooting your system after installing haveged and you should notice that SSH no longer times out and your boot process should be a lot faster as a result.
I hope that this article will be of use to someone encountering this same problem. If you have any questions or comments, please let me know by leaving a comment below.