I have been using the TortoiseGit tool to operate Git, but switching windows back and forth with the built-in support in VSCode feels quite awkward.
Today, I finally tried to commit and push using VSCode for the first time, but I received an error message:
Git: Host key verification failed
It may also appear in this form:
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
Solution:
Execute the following command
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
Source:
Failed to authenticate git remote
Or
Permission denied (publickey).
It is recommended to use SSH authentication.
-
Change the remote address to
[email protected]:wdssmq/HelloZBlog.gitformat; -
Open Git Bash and execute:
cd ~/.ssh
ssh-keygen -t ecdsa
# List the path of the .ssh folder
pwd
# c/Users/username/.ssh
- Find
id_ecdsa.pubin the corresponding path, open it with an editor, and copy its content to add to your GitHub account.
You can click the link to add directly:
Add new SSH keys: https://github.com/settings/ssh/new
After that, you can perform commit operations in VSCode;
ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type
Solution:
The RSA algorithm is considered no longer secure (mainly depending on key length);
A more direct method is to change the algorithm to ecdsa or ed25519, with the latter being more secure. However, if your environment is older and you receive the unknown key type ed25519 message, then choose the former;
ssh-keygen -t ed25519
# unknown key type ed25519
ssh-keygen -t ecdsa
Related:
Memo: msysGit Installation and Usage
VSCode Keyboard Shortcuts Memo
You can switch to Git management with ctrl + shift + g.