ssh连接报错

使用ssh远程连接服务器时报错解决方案
报错一:在使用ssh 公网ip地址时

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:APAQekG1WkP/2VYkQb42IpqvP74VHklIsaZyKiFSOYs.
Please contact your system administrator.
Add correct host key in /home/saber/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/saber/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/home/saber/.ssh/known_hosts" -R "8.219.56.85"
ECDSA host key for 8.219.56.85 has changed and you have requested strict checking.
Host key verification failed.

解决方法:ssh_keygen -R 公网ip地址
报错二:ssh 公网ip地址

The authenticity of host '8.219.56.85 (8.219.56.85)' can't be established.
ECDSA key fingerprint is SHA256:a4sRHxyVsWzmfkXhP2SFBTvthkmswLELmSs/8doUI0c.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

解决办法:修改本地机与服务器的ssh.config文件,将修改为StrictHostKeyChecking ask注释掉,将ask修改为no

vim /etc/ssh/ssh.config

报错三:ssh 公网ip地址

Warning: Permanently added '8.219.56.85' (ECDSA) to the list of known hosts.

解决办法:在本地机/root/.ssh下创建config文件,并在config文件中写入UserKnownHostsFile ~/.ssh/known_hosts

touch config
vim config

报错四:ssh 公网ip地址

root@8.219.56.85: Permission denied (publickey).

解决办法:在本地机下的.ssh下创建公钥与私钥,需要输入的,全部回车就好

ssh-keygen

我们可以看见,ssh下多了两个文件id_rsa与id_rsa.pub,id_rsa.pub为公钥,需要将其中内容复制到服务器秘钥下

tail id_rsa.pub

服务器上的操作,编辑秘钥

vim /root/.ssh/authorized_keys

相关文章

学习编程是顺着互联网的发展潮流,是一件好事。新手如何学习...
IT行业是什么工作做什么?IT行业的工作有:产品策划类、页面...
女生学Java好就业吗?女生适合学Java编程吗?目前有不少女生...
Can’t connect to local MySQL server through socket \'/v...
oracle基本命令 一、登录操作 1.管理员登录 # 管理员登录 ...
一、背景 因为项目中需要通北京网络,所以需要连vpn,但是服...