- Deprecated option RSAAuthentication
- sshd: no hostkeys available – exiting.
问题描述:pycharm通过ssh连接docker容器的时候连接失败了,提示:Server closed connection during identification exchange 以及 Error connecting to remote host 127.0.0.1
回到容器中重启ssh
service ssh restart
此时提示:
/etc/ssh/sshd_config line 125: Deprecated option RSAAuthentication
sshd: no hostkeys available – exiting.
修复上述错误,首先修复Deprecated option RSAAuthentication,删除过时的 RSAAuthentication 选项
- 编辑 SSH 配置文件:
sudo vim /etc/ssh/sshd_config
2. 查找并注释 RSAAuthentication 这一行
#RSAAuthentication yes
- 保存并退出: 在 vim 中按 Esc 键,然后输入 :wq 保存并退出。
再来修复sshd: no hostkeys available – exiting.的错误,即需要重新生成主机密钥
4. 新生成主机密钥`sudo ssh-keygen -A
5. 确保主机密钥已正确生成并存储在 /etc/ssh/ 目录下
常见的密钥文件包括:
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ed25519_key
6. 配置文件的权限,这一步也很重要
sudo chmod 600 /etc/ssh/ssh_host_*
sudo chown root:root /etc/ssh/ssh_host_*
- 完成以上更改后,在容器中重新启动 SSH 服务
sudo service ssh restart
如果ssh是直接装在主机上的,重启命令是sudo systemctl restart sshd
8. 查看ssh状态
sudo systemctl status sshd
显示ok
9. 完成 现在可以重新使用ssh连接容器啦