每次我使用git与遥控器交互时,比如拉或推时,我都会看到以下消息:
警告:永久添加'…' (RSA)到已知主机列表。
如何防止显示这个烦人的消息?这只是一个烦恼——一切都很正常。
每次我使用git与遥控器交互时,比如拉或推时,我都会看到以下消息:
警告:永久添加'…' (RSA)到已知主机列表。
如何防止显示这个烦人的消息?这只是一个烦恼——一切都很正常。
当前回答
在我的例子中,这是因为设置服务器的管理员在~/.ssh/config中设置了这些选项
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
在大多数情况下,不使用~/。ssh / known_hosts文件中。但是对于企业gitlab回购,每当它给出“警告:永久添加…”到已知的宿主名单。”
我的解决方案是注释掉UserKnownHostsFile /dev/null行,这允许创建~/.ssh/known_hosts。在那之后,它没有再给出任何警告。
在known_hosts中也可能有旧的/无效的条目。
# find entry in ~/.ssh/known_hosts
ssh-keygen -F <hostname>
# delete entry in ~/.ssh/known_hosts
ssh-keygen -R <hostname>
其他回答
在~/中设置LogLevel为ERROR(不是QUIET)。Ssh /config文件,以避免看到这些错误:
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
创建一个~/。Ssh /config文件并插入行:
UserKnownHostsFile ~/.ssh/known_hosts
然后,您将在下次访问Github时看到该消息,但在此之后,您将不再看到它,因为主机已添加到known_hosts文件。这可以修复问题,而不仅仅是隐藏日志消息。
这个问题困扰了我很长时间。出现此问题是因为为Windows编译的OpenSSH客户端没有检查~/.ssh/known_hosts中的known_hosts文件
SSH -vvv git@github.com
debug3: check_host_in_hostfile: filename /dev/null
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts
debug3: check_host_in_hostfile: filename /dev/null
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
我的情况下,我只得到ssh警告时使用Gridengine qrsh远程shell登录。然而,正常的ssh会像预期的那样工作(第一次发出警告,然后在随后的时间里保持安静)。
我的解决方案是手动填充~/。ssh/known_hosts与Gridengine可以选择的所有可能的服务器名称(使用qhost列出服务器):
for p in server1 server2 server3 server4; do
ssh-keyscan -H ${p}.company.com;
ssh-keyscan -H $(getent hosts $p | perl -lane 'print $F[0]');
done >> ~/.ssh/known_hosts
背景:
Gridengine is a job scheduler which can use ssh to select the least loaded server. The reason for the warning is that qrsh seem to always specify a non-standard port for doing the ssh connection, causing known_hosts to be updated with an entry also containing a port number. Next time when qrsh selects the same server there would be a new port-number and known_hosts would get updated with a new port-specific entry. The reason for also adding the raw host IP address is that some hosts used ecdsa-sha2-nistp521. If a raw IP entry is not added I would get the warning:
ECDSA host key for IP address '10.1.2.3' not in list of known hosts.
当我开始使用Windows电脑时,我也遇到了同样的问题。在我的例子中,这是因为我的SSH设置没有完成。Github有一个关于SSH设置的非常精确的文档。一旦解决了这个问题,问题就解决了。
https://help.github.com/articles/checking-for-existing-ssh-keys/ https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
该消息来自SSH,它警告您正在连接到一个您以前从未连接过的主机。我不建议关闭它,因为这意味着您可能会错过关于主机密钥更改的警告,这可能表明SSH会话受到MITM攻击。