1

I am getting error when I tried ssh for git.com.

Error: You need access to git with ssh

This was working fine until very recent.

Emma Deo
  • 38
  • 4

1 Answers1

3

The reason is recently GitHub.com’s RSA SSH private key was briefly exposed in a public GitHub repository. So they have changed their RSA SSH host key used to secure Git operations for GitHub.com

You can verify whether this is the exact reason by running below command.

ssh -vT git@github.com

If you see following warning, above causes the issue.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Run following commands to update the GitHub.com’s RSA SSH key in your machine

Step 1: Remove the old key by running this command:

ssh-keygen -R github.com 

Step 2: automatically update GitHub.com’s RSA SSH key in your ~/.ssh/known_hosts

curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts

refer https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/