如何解决“Offending key in ~/.ssh/known_hosts” file

服务器重装,导致在客户端服务器上同一个ip公钥不同(public key),在know_hosts里面有是加密的找不到原来IP的public key,因为服务器里面的业务很多又不能把know_hosts删掉。找了很久找到一个方法。


Remove the offending ssh key

Following error will be displayed when the remote host key changes (after you’ve connected earlier with a valid remote host key).


[javascript]  view plain copy
  1. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
  2. @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @  
  3. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  
  4. IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!  
  5. Someone could be eavesdropping on you right now (man-in-the-middle attack)!  
  6. It is also possible that the RSA host key has just been changed.  
  7. The fingerprint for the RSA key sent by the remote host is  
  8. a7:a8:f2:97:94:33:58:b7:9d:bc:e0:a6:6b:f7:0a:29.  
  9. Please contact your system administrator.  
  10. Add correct host key in /home/ramesh/.ssh/known_hosts to get rid of this message.  
  11. Offending key in /home/ramesh/.ssh/known_hosts: 6  
  12. Permission denied (publickey,password).  

You have to remove the key to proceed further. Use the following command to remove the offending key.

[javascript]  view plain copy
  1. # sed -i '6d' ~/.ssh/known_hosts  

Note: Change the 6d according to the line number shown.

If your sed does not have -i option, use perl or use some editor to remove the offending key.

Perl solution:

[javascript]  view plain copy
  1. # perl -pi -e 's/\Q$_// if ($. == 6);' ~/.ssh/known_hosts  

Note: Change the line number from 6 to appropriate line number.


原文地址:http://blog.csdn.net/fisher_jiang/article/details/7351343

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值