Git says “Warning: Permanently added to the list o

2019-03-07 09:35发布

Every time I use git to interact with a remote, such as when pulling or pushing, I am shown the following message:

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.

12条回答
女痞
2楼-- · 2019-03-07 10:08

I am taking my solution down due to continued downvotes.
It was the best solution without actually hacking the source code of the SSH client itself.
If someone is interested, check the edit history.

查看更多
倾城 Initia
3楼-- · 2019-03-07 10:09

Add the following line to your ssh config file ($HOME/.ssh/config):

LogLevel=quiet

If running ssh from the command line add the following option to the command string:

-o LogLevel=quiet

For example, the following prints out the gcc version installed on machine.example.org (and no warning):

ssh -o UserKnownHostsFile=/dev/null \
    -o StrictHostKeyChecking=no \
    -o LogLevel=quiet \
    -i identity_file \
    machine.example.org \
    gcc -dumpversion
查看更多
啃猪蹄的小仙女
4楼-- · 2019-03-07 10:11

It mainly means there are changes for the key for that host ~/.ssh/known_hosts, and it will not automatically UPDATE it. Therefore every time you get this warning message.

This happens often for the connecting to the re-created virtual machines, which changes the key with the same IP address

Solution

If you only have one entry, then you can delete the ~/.ssh/known_hosts file, and after first connection, that the key will be there, and no warning messages after that.

If you have multiple entries, then you can use command below to remove

$ ssh-keygen -R <hostname>

It works fine for me

查看更多
▲ chillily
5楼-- · 2019-03-07 10:17

If you are using a repository from GitHub, consider using the HTTPS version of the URL instead, to sidestep this problem entirely:

Click the HTTP button and clone that URL instead

If you clone your repository from within the Windows GitHub application, this is what it uses for the remote URL. Maybe they know something we don't know.

查看更多
Animai°情兽
6楼-- · 2019-03-07 10:19

I have the same question, and I found there is not a .ssh file in my ~. So I just create the .ssh directory under ~ path, and the issue solved.

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-03-07 10:19

I got into the same issue when I started using a Windows machine. In my case it was because my SSH setup was not done. Github has a very precise documentation on the SSH setup. Once that's taken care, the issue was resolved.

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/

查看更多
登录 后发表回答