Git说“警告:永久添加到已知主机列表” [英] Git says "Warning: Permanently added to the list of known hosts"
问题描述
每次我使用git与远程进行交互时,例如当拉或推时,我会看到以下消息:
Every time I use git to interact with a remote, such as when pulling or pushing, I am shown the following message:
警告:将已知主机列表中的...(RSA)永久添加。
Warning: Permanently added '...' (RSA) to the list of known hosts.
如何防止此恼人的邮件显示?这只是一个麻烦 - 一切正常工作。
How can I prevent this annoying message from displaying? It is only an annoyance—everything functions properly.
推荐答案
这个问题困扰我很多时间。问题是,他们为Windows编译的OpenSSH客户端不检查〜/ .ssh / known_hosts中的known_hosts文件
This problem was bugging me for quite some time. The problem is, the OpenSSH client they've compiled for Windows doesn't check the known_hosts file in ~/.ssh/known_hosts
ssh -vvvvvvvvvvvvvvvvvvv git@github.com
ssh -vvvvvvvvvvvvvvvvvvv 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 / config文件并插入行:
The answer is to create a ~/.ssh/config file and insert the line:
UserKnownHostsFile ~/.ssh/known_hosts
然后,您将在下次访问Github时看到此消息,但之后,在将主机添加到known_hosts文件后,您将看不到该消息。这实际上解决了问题,而不是只隐藏日志消息。
You will then see the message the next time you access Github, but after that you'll not see it anymore as the host is added to the known_hosts file. This actually fixes the issue, rather than just hiding the log message.
这篇关于Git说“警告:永久添加到已知主机列表”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!