Generally, when using SSH in Linux, if this error occurs, we recommend that you first check the log.
The SSH logs of ubuntu are stored in/var/log/auth. log.
Log errors are similar to the following:
Dec 22 09:43:31 x079-liongao sshd[14883]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:31 x079-liongao sshd[14883]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @Dec 22 09:43:31 x079-liongao sshd[14883]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:31 x079-liongao sshd[14883]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.Dec 22 09:43:31 x079-liongao sshd[14883]: error: It is recommended that your private key files are NOT accessible by others.Dec 22 09:43:31 x079-liongao sshd[14883]: error: This private key will be ignored.Dec 22 09:43:31 x079-liongao sshd[14883]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_keyDec 22 09:43:31 x079-liongao sshd[14883]: error: Could not load host key: /etc/ssh/ssh_host_dsa_keyDec 22 09:43:35 x079-liongao sudo: liongao : TTY=pts/3 ; PWD=/home/liongao ; USER=root ; COMMAND=/usr/bin/ssh localhostDec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:35 x079-liongao sshd[14892]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:35 x079-liongao sshd[14892]: error: Permissions 0777 for '/etc/ssh/ssh_host_rsa_key' are too open.Dec 22 09:43:35 x079-liongao sshd[14892]: error: It is recommended that your private key files are NOT accessible by others.Dec 22 09:43:35 x079-liongao sshd[14892]: error: This private key will be ignored.Dec 22 09:43:35 x079-liongao sshd[14892]: error: bad permissions: ignore key: /etc/ssh/ssh_host_rsa_keyDec 22 09:43:35 x079-liongao sshd[14892]: error: Could not load host key: /etc/ssh/ssh_host_rsa_keyDec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:35 x079-liongao sshd[14892]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @Dec 22 09:43:35 x079-liongao sshd[14892]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:35 x079-liongao sshd[14892]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.Dec 22 09:43:35 x079-liongao sshd[14892]: error: It is recommended that your private key files are NOT accessible by others.Dec 22 09:43:35 x079-liongao sshd[14892]: error: This private key will be ignored.Dec 22 09:43:35 x079-liongao sshd[14892]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_keyDec 22 09:43:35 x079-liongao sshd[14892]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Obviously, it is about permissions. You only need to correct all the files in the/etc/ssh directory to the correct permissions. If you do not know how much to change to, you can check the directory permissions after successful installation of SSH by default. You 'd better uninstall SSH and reinstall it again.