SSH Error Invalid Format – Ubuntu 18.04
This article is a troubleshoot documentation about problems with SSH Server on the Ubuntu Server 18.04 operating system.
Problems:
When Ubuntu Server 18.04 has not been installed SSH Server then we install the new SSH Server package, but from the SSH Client it cannot connect and there is an error message as follows:
Unexpectedly closed network connection server
Network error: Software caused connection abort
Connection closed by 192.168.2.106 port 22
ssh: connect to host 192.168.20.106 port 22: Connection refused
Log output at: /var/log/auth.log
Nov 18 03:59:56 localhost sshd[10704]: error: key_load_private: invalid format
Nov 18 03:59:56 localhost sshd[10704]: error: key_load_public: invalid format
Nov 18 03:59:56 localhost sshd[10704]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Cause:
Format host key rsa,ecdsa,ed25519 are invalid / wrong.
Solution:
Generate suitable new formats:
ssh-keygen -A
Restart SSH Server Services:
systemctl restart sshd