So, the problem arised when I tried to clone a Git repository from github using below command: git clone git@github.com:user-name/repo-name.git But I failed with below error: Cloning into 'repo-name'... The authenticity of host 'github.com (20.205.243.166)' can't be established. ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. |
Possible solution is Create SSH key pair The process is as below: |
1. Open Git Bash and run command ssh-keygen -t rsa -b 4096 -C "your_email@example.com" 2. Accepts the default file location (using Enter key) 3. Set SSH key passphrases or hit Enter button twice - will generate private and public key. 4. Your identification has been saved in /c/Users/user-name/.ssh/id_rsa... if you don't change location. 5. Copy the SSH key to your clipboard using command clip < /c/Users/HP/.ssh/id_rsa.pub. 6. Time to set key to github account, go to https://github.com/settings/profile 7. Then go to SSH and GPG keys and click on New SSH key button and paste SSH key to the big text box (Make sure you remove your email address from SSH key at end): 8. You are done from github end. 9. Now you can clone your GitHub repo and it will not complain about git@github.com permission denied (publickey). fatal could not read from remote repository |
10. It's time to try again to clone repo using Git Bash. 11. Execute command git clone git@github.com:user-name/repo-name.git and let's see what happen 12. So it's done, repo clonned successfully: |
Benefits of this approach
|
Wednesday, January 11, 2023
How to fix - git@github.com permission denied (publickey). fatal could not read from remote repository and Support for password authentication was removed. Please use a personal access token instead - Git: How to solve Permission denied (publickey) error when using Git - Fix "Permission denied (publickey)" error when pushing with Git
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment