每次我使用git与遥控器交互时,比如拉或推时,我都会看到以下消息:

警告:永久添加'…' (RSA)到已知主机列表。

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


当前回答

要屏蔽ssh的警告消息,可以在~/.ssh/config中添加以下行:

Host *
LogLevel error

这将禁用警告,但不会禁用错误消息。就像~/中的其他设置一样。如果你想要一个更细粒度的控制,你可以在每个主机上配置LogLevel。

其他回答

我有同样的问题,我发现没有一个.ssh文件在我的~。所以我只是在~路径下创建了.ssh目录,问题就解决了。

要屏蔽ssh的警告消息,可以在~/.ssh/config中添加以下行:

Host *
LogLevel error

这将禁用警告,但不会禁用错误消息。就像~/中的其他设置一样。如果你想要一个更细粒度的控制,你可以在每个主机上配置LogLevel。

在ssh配置文件($HOME/.ssh/config)中添加以下行:

LogLevel=quiet

如果从命令行运行ssh,在命令字符串中添加以下选项:

-o LogLevel=quiet

例如,下面打印在machine.example.org上安装的gcc版本(没有警告):

ssh -o UserKnownHostsFile=/dev/null \
    -o StrictHostKeyChecking=no \
    -o LogLevel=quiet \
    -i identity_file \
    machine.example.org \
    gcc -dumpversion

当我开始使用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 /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.