windows本地无法ssh连接远程服务器解决笔记!

2022-01-06  本文已影响0人  DragonersLi

原因:Linux服务器重装或则openssh-server重装引起的,最快解决办法是删除本地know_hosts文件

C:\Users\DragonersLi\.ssh>type config #查看config配置的远程登录信息

Host xxx_host
HostName 114.xx.xx.214
User root
Port 80

...

登录报错

C:\Users\DragonersLi>ssh xxx_host
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uo1OpqAHroU4BED0etErwfb6nOobAi4/KLaiqKW8ONQ.
Please contact your system administrator.
Add correct host key in C:\\Users\\DragonersLi/.ssh/known_hosts to get rid of this message.
Offending ED25519 key in C:\\Users\\DragonersLi/.ssh/known_hosts:5
RSA host key for [114.xx.xx.214]:80 has changed and you have requested strict checking.
Host key verification failed.

ssh-keygen -R IP或域名,试了没用

C:\Users\DragonersLi>ssh-keygen -R 114.xx.xx.214
Host 114.xx.xx.214 not found in C:\\Users\\DragonersLi/.ssh/known_hosts
C:\Users\DragonersLi\.ssh>dir  #查看目录 
 Volume in drive C is 系统
 Volume Serial Number is F211-DC4F

 Directory of C:\Users\DragonersLi\.ssh

2022/01/06  12:50    <DIR>          .
2022/01/05  19:31    <DIR>          ..
2021/12/09  11:27               298 config
2021/06/30  18:52             2,610 id_rsa
2021/06/30  18:52               582 id_rsa.pub
2021/12/24  20:51               860 known_hosts
               4 File(s)          4,350 bytes
               2 Dir(s)  12,221,812,736 bytes free

C:\Users\DragonersLi\.ssh>type known_hosts #查看文件
[114.xx.xx.214]:80 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK53SmBLOSTxYPTEoWcxAtAB/yL9yaVCZq0j+u8jXqfT
...

删除本地know_hosts文件后,正常登录。但这样会丢失之前保存的其他主机信息
登录其它服务器会重新要输入yes确认

C:\Users\DragonersLi\.ssh>del known_hosts
 
C:\Users\DragonersLi\.ssh>ssh xxx_host
The authenticity of host '[114.xx.xx.214]:80 ([114.xx.xx.214]:80)' can't be established.
RSA key fingerprint is SHA256:uo1OpqAHroU4BED0etErwfb6nOobAi4/KLaiqKW8ONQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[114.xx.xx.214]:80' (RSA) to the list of known hosts.
Last login: Thu Jan  6 12:26:43 2022 from 115.204.196.xxx

Welcome to Alibaba Cloud Elastic Compute Service !
[root@paijinhua ~]# ^C
[root@paijinhua ~]# exit
logout
上一篇下一篇

猜你喜欢

热点阅读