I'm trying to connect to a new Ubuntu server. I was using the hardware of this server previously (with Desktop Ubuntu) before installing Ubuntu server. Do you know what can be happening?
Bernardos-MacBook-Pro:~ bernardo$ ssh [email protected]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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:4cTDTZMivYKNPugdQQlwGDKcV6FvnSTsY7jAf0hW7Q0.
Please contact your system administrator.
Add correct host key in /Users/bernardo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/bernardo/.ssh/known_hosts:28
ECDSA host key for 192.168.1.43 has changed and you have requested strict checking.
Host key verification failed.
Bernardos-MacBook-Pro:~ bernardo$ ssh-keygen -R 192.168.1.123
Host 192.168.1.123 not found in /Users/bernardo/.ssh/known_hosts
Bernardos-MacBook-Pro:~ bernardo$ sed -i '28d' ~/.ssh/known_hosts
sed: 1: "/Users/bernardo/.ssh/kn ...": undefined label 'ernardo/.ssh/known_hosts'
手动删除第 28 行后
Bernardos-MacBook-Pro:~ bernardo$ ssh [email protected]
The authenticity of host '192.168.1.43 (192.168.1.43)' can't be established.
ECDSA key fingerprint is SHA256:4cTDTZMivYKNPugdQQlwGDKcV6FvnSTsY7jAf0hW7Q0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.43' (ECDSA) to the list of known hosts.
Permission denied (publickey).
答案1
安装sshd
将自动安装主机密钥。连接到主机时,客户端将检查它是否已经拥有您尝试连接的主机的密钥。如果没有,它会询问您是否可以安全连接到该主机。如果有,并且与之前相同,它不会询问任何问题。但是如果它已经有密钥并且它是不同的,它知道它没有连接到它之前连接的同一个操作系统安装,并且它假设出了问题。在这种情况下,您重新安装了操作系统而没有费心保存并重新安装以前的主机密钥,但您的 SSH 客户端不知道,其他人可能正在尝试冒充您的主机。
要消除此错误,请从您的
~/.ssh/known_hosts
至于为什么不能用命令删除该行sed
,我同意@user1700494 的理论;用来man sed
看看你的sed
支持是什么。
答案2
我不用 OS X,但我知道 OS Xsed
不是 GNU sed
。我猜你sed
不理解-i
密钥。你需要手动删除第 28 行的条目/Users/bernardo/.ssh/known_hosts
或安装gnu-sed
答案3
Please contact your system administrator.
Add correct host key in /Users/bernardo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/bernardo/.ssh/known_hosts:28
您手动完成此操作并得到:
Permission denied (publickey)
听起来您需要在服务器上启用基于密码的登录,或者将您的公钥添加到authorized_users
服务器上的文件中。