OpenSSH的known_hosts引发的问题

Ubuntu 15.4

http://blog.csdn.net/u013686019/article/details/54574119

在使用OpenSSH的时候,如果没有特别指定目录,known_hosts文件存在于:

~/.ssh/

目录下。 known_hosts记录了本机访问过的计算机的pubic key。


这两天从服务器同步Android源码,执行repo sync后总是卡在连接服务器的位置:

Get ssh://git@www.xxxxxx.com.cn/gerrit/android/platform/manifest
Warning: the ECDSA host key for 'www.xxxxxx.com.cn' differs from the key for the IP address '192.168.1.9'
Offending key for IP in /home/gerrit/.ssh/known_hosts:1
Matching host key in /home/gerrit/.ssh/known_hosts:3
Are you sure you want to continue connecting (yes/no)? yes
Warning: the ECDSA host key for 'www.xxxxxx.com.cn' differs from the key for the IP address '192.168.1.9'
Offending key for IP in /home/gerrit/.ssh/known_hosts:1
Matching host key in /home/gerrit/.ssh/known_hosts:3
Are you sure you want to continue connecting (yes/no)? yes

怎么办呢?那就调试找原因。在一台没有访问过Android源码服务器的机器上执行同步,完全没问题;看到上述终端输出提到 known_hosts文件,就查找了下该文件的相关信息。接着就是测试,为方便故,直接把~/.ssh/known_hosts文件删除了,这是终端输出如下:

Get ssh://git@www.xxxxxx.com.cn/gerrit/android/platform/manifest
The authenticity of host 'www.xxxxxx.com.cn (192.168.1.9)' can't be established.
ECDSA key fingerprint is 4e:a5:bc:9c:92:94:29:e4:4a:12:94:fe:54:b2:4e:b0.
Are you sure you want to continue connecting (yes/no)? The authenticity of host 'www.xxxxxx.com.cn (192.168.1.9)' can't be established.
ECDSA key fingerprint is 4e:a5:bc:9c:92:94:29:e4:4a:12:94:fe:54:b2:4e:b0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'www.xxxxxx.com.cn,192.168.1.9' (ECDSA) to the list of known hosts.

看内容这是要重新生成~/.ssh/known_hosts。

终止操作,重新repo init/repo sync,就再没有任何问题了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OpenSSH_9.2p1 Debian-2, OpenSSL 3.0.9 30 May 2023 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to lxslc702.ihep.ac.cn [2401:de00:2:332::186] port 22. debug1: Connection established. debug1: identity file /home/fyf/.ssh/id_rsa type -1 debug1: identity file /home/fyf/.ssh/id_rsa-cert type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/fyf/.ssh/id_ed25519 type -1 debug1: identity file /home/fyf/.ssh/id_ed25519-cert type -1 debug1: identity file /home/fyf/.ssh/id_ed25519_sk type -1 debug1: identity file /home/fyf/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/fyf/.ssh/id_xmss type -1 debug1: identity file /home/fyf/.ssh/id_xmss-cert type -1 debug1: identity file /home/fyf/.ssh/id_dsa type -1 debug1: identity file /home/fyf/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: compat_banner: match: OpenSSH_7.4 pat OpenSSH_7.4* compat 0x04000006 debug1: Authenticating to lxslc702.ihep.ac.cn:22 as 'fanyufan' debug1: load_hostkeys: fopen /home/fyf/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/fyf/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY Connection closed by 2401:de00:2:332::186 port 22
07-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值