GitHub not accepting public SSH key: fix it by switching from HTTP(S) to SSH in the Git repository config
If you clone a Git repository from GitHub via the HTTPS URL, which is placed in the section as shown below, than your public SSH key will not be recognized by GitHub.
You can test your public SSH key for GitHub usage by the following command:
ssh -T email@example.com
If you have chosen the wrong HTTPS option before (it must be SSH), you can fix that by the following steps.
- Open the file at .git/config
- Look for
url = http://github.com/path/to/repository or url = https://github.com/path/to/repository
- Replace it by
url = ssh://firstname.lastname@example.org/path/to/repository
- Save the file and GitHub will accept the public SSH key on the next push. No username and password typing anymore.