SOLVED: error: Could not load host key: /etc/ssh/ssh_host_rsa_key

If you can ping your server but receive a "Connection closed by [VPS IP]" when trying to establish an SSH connection, connect to your VPS through VNC and check your /var/log/auth.log for the following error:
error: Could not load host key: /etc/ssh/ssh_host_rsa_key
error: Could not load host key: /etc/ssh/ssh_host_dsa_key
error: Could not load host key: /etc/ssh/ssh_host_ecdsa_key

If this is the case, this can be fixed easily by running the following commands:
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


If this problem still persists then do the following.

service sshd stop
rm -rf /etc/ssh
yum erase openssh-server
yum install openssh-server
service sshd start
chkconfig sshd start
  • 11 Users Found This Useful
Was this answer helpful?

Related Articles

Cheapest Linux VPS Hosting in the world!

Access the best web hosting vps to enhance the efficiencyWeb hosting is an obligatory service if...

Virtual Hosting with Apache Linux Server

How to Setup Multiple Hosts on ApacheIt's the example to configure virtual hostings. Following...

Install MySQL for Database Server on CentOS VPS

 Install MySQL for Database Server. [root@www ~]# yum -y install mysql-server...

Add a HardDrive to Your Linux VPS

 This is an example to create a partition when you add a new hard drive. root@dlp:~#...

HowTo: Shrink size of ext4 LVM logical volume

HowTo: Shrink size of ext4 LVM logical volume LVM, the Logical Volume Manager, is...