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

来源:互联网 发布:投诉了淘宝卖家会怎样 编辑:程序博客网 时间:2024/05/24 07:02

远程的电脑是个新安装的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.21OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /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 1debug1: identity file /home/ubuntu/.ssh/id_rsa-cert type -1debug1: identity file /home/ubuntu/.ssh/id_dsa type -1debug1: identity file /home/ubuntu/.ssh/id_dsa-cert type -1debug1: identity file /home/ubuntu/.ssh/id_ecdsa type -1debug1: identity file /home/ubuntu/.ssh/id_ecdsa-cert type -1debug1: identity file /home/ubuntu/.ssh/id_ed25519 type -1debug1: identity file /home/ubuntu/.ssh/id_ed25519-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000debug1: SSH2_MSG_KEXINIT sentConnection 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/waitingssh start/running, process 12683

连接就ok了

参考链接:https://stackoverflow.com/questions/2419412/ssh-connection-stop-at-debug1-ssh2-msg-kexinit-sent

阅读全文
0 0
原创粉丝点击