[How to solve] Could not load host key: /etc/ssh/ssh_host_rsa_key issue in FreeBSD or Linux

[How to solve] Could not load host key: /etc/ssh/ssh_host_rsa_key issue in FreeBSD or Linux

Sometimes while starting the sshd service you may face some issues like the following:

Could not load host key: /etc/ssh/ssh_host_key
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.

Usually these security keys should have been created during the installation itself but if in the sshd configuration file it is not mentioned to create them automatically then you will definitely miss the keys and without these keys your sshd will not start. Well in such case either you set the corresponding sshd configuration file and restart your system or you can manually generate the keys.
Personally I would suggest you to create these keys manually because finding the sshd configuration file is another overhead task because different systems have their sshd configuration files at different places.

How to manually create the keys for the Could not load host key: /etc/ssh/ssh_host_rsa_key issue:

ssh-keygen -A


ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_key
ssh-keygen -b 1024 -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -b 1024 -t dsa -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -b 1024 -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key

The first command will automatically generate all the required keys.
But the second command will be helpful if you want to create only one of those keys and not all. But I really do not see any difference of using the second step because the ssh-keygen -A will take care of creating the ssh keys for which there is no key has been generated yet.
In the second command the -b 1024 option specifies the key will be of 1024 bit length.
And the -t option specifies the type of key: either rsa, dsa or ecdsa.


Sometimes the ssh is not at all installed on your system or you missed out to enable the ssh package while installing the OS. How you will come to know if ssh is installed or not?? just type ssh in your command prompt and to surprise you will see that command is not found or similar text.
Well, in such case you just see how to install a package in your system. For example:
In ubuntu: sudo apt-get install openssh-server will work
In freebsd: pkg install ssh or pkg install openssh will work.

Well I think this will mostly help you out to solve Could not load host key: /etc/ssh/ssh_host_rsa_key issue. If not then comment in the comment box and I will surely help you out.

Previous Fully loaded Yu Yuphoria launched for Rs 6999
Next How to Unload a Module in Linux or Blacklist Module in Grub

About author

siba 698 posts

A B.Tech degree holder with more than 5 years of experience on Embedded Systems design domain. He has worked on Aerospace domain, NAND storage, Server storage and Wireless networking.

View all posts by this author →

You might also like

FreeBSD Guides 0 Comments

[FreeBSD] How to set and unset loader variables in boot loader prompt

Important question is why you need to set and unset variables at boot time??? The answer is when something is stopping you from booting your system then this may help

FreeBSD Guides 0 Comments

[FreeBSD] How to Install FreeBSD OS, Step by step guide using a virtual machine

Take a deep breathe and be sure that you have at least an hour of time. We have to go a long way towards an important step. Before going into

FreeBSD Guides 0 Comments

[FreeBSD] How to install VIM editor in FreeBSD

By default FreeBSD comes in a command line user interface. As an Administrator or a Device Drive developer or as a FreeBSD user, you must be having a good text


No Comments Yet!

You can be first to comment this post!