How-To Fix: “regenerate_ssh_host_keys …failed” on Raspbian for RaspberryPi

Listen to me!
Audio MP3

download mp3
During your RPi boot it may happen that you get an error message like, “regenerate_ssh_host_keys …failed”, such error is generally sign that you SSH service won’t start.

That issue showed to me during the second boot of Raspbian on my new RsberryPi Revision B, due to the fact that during the previous session I did forcibly quit the raspi-config configuration tool exactly after issuing the command to enable the SSH server.

That caused the configuration process not to run the one-time operation of generating the ssh host keys necessary to run the sshd daemon. If fact, at the second reboot of Raspbian the script /etc/init.d/regenerate_ssh_host_keys (sim-linked by /etc/rc2.d/S01regenerate_ssh+host_keys), was  deleted as scheduled, but failed to start the SSH server because there were not the ssh keys supposed to be generated at the previous session.

The solution to the problem consists in manually generate the SSH keys and start the SSH server, executing the following commands:

~$ sudo ssh-keygen -t 'rsa' -f /etc/ssh/ssh_host_rsa_key
~$ sudo ssh-keygen -t 'dsa' -f /etc/ssh/ssh_host_dsa_key
~$ sudo ssh-keygen -t 'ecdsa' -f /etc/ssh/ssh_host_ecdsa_key

If requested for a password during the generation of these keys it’s advisable to leave it blank (empty) as they are ‘host’ keys and not personal keys.
Also confirm that you want to overwrite possible pre-existing keys that could be a partial leftover of the previously aborted generation process.

Please feel free to leave any comment and amend.

Comments

comments

Powered by Facebook Comments

About marcomc

Marco M.C. is a System Administrator with 10 years of professional experience in ICT. He has deep knowledge of Mac OS X, Windows, and GNU/Linux. His hobbies vary from DIY, Traveling, learning foreign languages and especially he love to cook and experiment with food from all around the world.
This entry was posted in How-To, IT, Linux, RaspberryPi and tagged , . Bookmark the permalink.