Generate sshd host key

If you’re getting this error when trying to start sshd:

Could not load host key: /etc/ssh/ssh_host_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Disabling protocol version 1. Could not load host key
Disabling protocol version 2. Could not load host key

Re-generate your host key with this command:

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

That should get you sorted, make sure you tell everyone who accesses the server with secure shell that the host key has changed, because they’ll get warnings about it and may think that the server’s been compromised.



One Response to “Generate sshd host key”

  1. Marcus Wanner says:

    Thanks, works great for the new rsa keys as well, just substitute “rsa” for “dsa” in both places.

    Also note that this updates the .pub file and sets the correct permissions (0600) for the private key file, so you don’t need to do anything extra there.

    Prepare for an amageddon’s worth of security warnings when you try to connect on ssh, though…

Leave a Reply

You must be logged in to post a comment.