您的位置:首页 > 其它

解决ssh中的”Connection closed by 10.0.0.21“问题

2017-12-19 10:18 309 查看
远程的电脑是个新安装的ubuntu,在本地执行ssh时,出现错误”Connection closed by 10.0.0.21“。

解决步骤:

首先保证远程PC的ssh 服务启动,使用命令ps -e | grep ssh查看,出现以下信息说明服务已经开启。

12570 ?        00:00:00 sshd

然后现在命令行中加入 -v,如下

ssh -v ubuntu@10.0.0.21

会出现一系列打印信息:

ubuntu@ubuntu-ThinkPad-X220:~$ ssh -v ubuntu@10.0.0.21
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.0.0.21 [10.0.0.21] port 22.
debug1: Connection established.
debug1: identity file /home/ubuntu/.ssh/id_rsa type 1
debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa type -1
debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1
debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1
debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 10.0.0.21


发现是本地机器将SSH2_MSG_KEXINIT 发送过去后,远程机器断开连接。怀疑是对方的key还未生成,执行命令sudo dpkg-reconfigure openssh-server

出现打印信息如下:

[sudo] password for ubuntu:
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
Creating SSH2 ED25519 key; this may take some time ...
ssh stop/waiting
ssh start/running, process 12683
连接就ok了

参考链接:https://stackoverflow.com/questions/2419412/ssh-connection-stop-at-debug1-ssh2-msg-kexinit-sent
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐