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

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

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


当前回答

创建一个~/。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 /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.

您只需要这个命令。

如果是,使用GitHub:

ssh -T git@gitlab.com

如果你使用GitLab:

ssh -T git@gitlab.com

添加ssh密钥

ssh-keygen -t rsa -b 4096 -C "abc@abc.com"

eval "$(ssh-agent -s)"

ssh-add ~/.ssh/bitbucket_rsa

机箱配置文件

crate ~/.ssh/config

加到下面一行。

UserKnownHostsFile ~/.ssh/known_hosts

然后添加pub密钥和克隆您的存储库…做……

在~/中设置LogLevel为ERROR(不是QUIET)。Ssh /config文件,以避免看到这些错误:

Host *
   StrictHostKeyChecking no
   UserKnownHostsFile /dev/null
   LogLevel ERROR

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