Cer*_*rin 387 security ssh ubuntu-server ssh-keys
我正在尝试在 Ubuntu 服务器上设置无密码 SSH ssh-copy-id myuser@myserver,但出现错误:
警告:“myserver”的 ECDSA 主机密钥与 IP 地址“192.168.1.123”的密钥不同
这是什么原因造成的,我该如何解决?我尝试删除.ssh远程机器上的目录,并在ssh-keygen -R "myserver"本地运行,但这并不能解决错误。
use*_*686 583
删除192.168.1.123本地计算机上的缓存密钥:
ssh-keygen -R 192.168.1.123
Run Code Online (Sandbox Code Playgroud)
aar*_*rkk 100
在我的情况下ssh-keygen -R ...没有修复警告。我有这样的额外信息:
Offending key for IP in /home/myuser/.ssh/known_hosts:8
Matching host key in /home/myuser/.ssh/known_hosts:24
Run Code Online (Sandbox Code Playgroud)
我只是手动编辑~/.ssh/known_hosts并删除了第 8 行(“违规键”)。我尝试重新连接,主机被永久添加,之后一切正常!
Chr*_*s K 22
我在我的 LAN 计算机和我的两个虚拟主机帐户之间进行了大量的 ssh-ing,所以我整理了各种 SSH 的零碎问题,包括使用身份验证问题ssh -v来查看哪里出了问题以及哪里出了问题。
刚刚解决了这个问题并且对答案不满意,我想真正知道“为什么”自己......
我的情况的触发因素是:在工作中安装了新的服务器操作系统,并且在安装 openssh-server 软件包后,在工作的服务器上生成了一组新的主机密钥。以前,我所有的服务器操作系统都是 Ubuntu,这次它改为 Debian(我怀疑在权限方面存在细微差别)。
当所有操作系统都是 Ubuntu 并且我重新安装服务器的操作系统时,在第一个 SSH 进入它时,我收到这种警告,我更喜欢上面的静默警告!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
06:ea:f1:f8:db:75:5c:0c:af:15:d7:99:2d:ef:08:2a.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:4
RSA host key for domain.com has changed and you have requested strict checking.
Host key verification failed.
Run Code Online (Sandbox Code Playgroud)
然后我~/.ssh/known_hosts在启动 ssh 的计算机上打开,删除该行,重新连接,发生这种情况:
chris@home ~ $ ssh work
The authenticity of host '[work]:11122 ([99.85.243.208]:11122)' can't be established.
ECDSA key fingerprint is 56:6d:13:be:fe:a0:29:ca:53:da:23:d6:1d:36:dd:c5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[work]:11122 ([99.85.243.208]:11122)' (ECDSA) to the list of known hosts.
Linux rock 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64
Run Code Online (Sandbox Code Playgroud)
关于 :11122 的那一点是我在防火墙上路由 SSH 的端口号
我检查了以前 Ubuntu 服务器的备份,并与我的新 Debian 安装进行了比较:
Ubuntu: Debian:
# Package generated configuration file # Package generated configuration file
# See the sshd(8) manpage for details # See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for # What ports, IPs and protocols we listen for
Port 22 Port 22
# Use these options to restrict which interface # Use these options to restrict which interfaces
#ListenAddress :: #ListenAddress ::
#ListenAddress 0.0.0.0 #ListenAddress 0.0.0.0
Protocol 2 Protocol 2
# HostKeys for protocol version 2 # HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_dsa_key
------------------------------------------------ HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security #Privilege Separation is turned on for security
UsePrivilegeSeparation yes UsePrivilegeSeparation yes
Run Code Online (Sandbox Code Playgroud)
所以是的,很可能,主机最近开始使用 ecdsa 密钥,这是基于 Ubuntu 最近的变化,我会归咎于更新。Ubuntu 摆脱了我所依赖的坚如磐石的 linux 操作系统,这就是我这次安装 Debian 的原因。
我在 ecdsa 上阅读了security.SE q/a并且已经从sshd_config我的新 Debian 服务器中删除了该行。(并跑了service ssh restart)
小智 8
我在 ~/.ssh/config 中添加了以下几行,从而禁用了对所有 .local 地址的严格主机检查。(使用DHCP地址分配,我本地机器的ip地址一直在变化)
host *.local
StrictHostKeyChecking no
Run Code Online (Sandbox Code Playgroud)
不过,您仍然会收到警告,这对我来说很好。
小智 7
ssh-keygen -f "/root/.ssh/known_hosts" -R 192.168.1.123
这应该替换 known_hosts.old 下的现有密钥并创建一个新密钥。这个解决方案在相同的场景中对我有用
| 归档时间: |
|
| 查看次数: |
518739 次 |
| 最近记录: |