Git 说 "Warning: Permanently added to the list of known hosts"

标签 git shell command-line ssh terminal

每次我使用 git 与远程交互时,例如 pull 或推时,都会显示以下消息:

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

如何防止显示这条烦人的消息?这只是一个烦恼——一切正常。

最佳答案

创建一个 ~/.ssh/config 文件并插入以下行:

UserKnownHostsFile ~/.ssh/known_hosts

您将在下次访问 Github 时看到该消息,但之后您将不会再看到它,因为主机已添加到 known_hosts 文件中。这解决了问题,而不仅仅是 stash 日志消息。

这个问题困扰了我一段时间。出现此问题是因为为 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.

关于Git 说 "Warning: Permanently added to the list of known hosts",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9299651/

相关文章:

git - 使用 Git 跟踪第三方代码

shell - Julia - 运行脚本并保持解释器运行

linux - 包含括号的 awk 协进程的转义序列

bash - 我怎样才能对带有前导零的数字变量进行 bash 算术运算?

bash - 将多个命令的输出重定向到一个文件

git - git中如何查看最后修改的文件路径?

git - 从 Bitbucket 中提取 Storyboard 时出现问题

c++ - 在 C++ ubuntu linux 中运行 shell 命令时出错

c - 在命令行程序中将选项与非选项参数分开

将 core.logAllRefUpdates 设置为 true 的裸存储库中的 git reflog 不返回任何内容