SSH keys set up but GitHub still asks for password #23171
-
Hi, I have set up and double-checked my SSH keys.; running “ssh -T git@github.com” gives a message “You’ve been successfully authenticated …”. However, when trying to run “git push”, I still get the Username/Password prompts. I expected that the SSH keys will function as a password-less authentication mechanism, just like they do on Linux and other UNIXes, but that does not happen. What am I missing? Thanks for your time and help. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
You’ll have to also adjust the remote URL your local repository uses to access your Github repository. That URL decides which protocol (SSH or HTTPS) Git uses. You can find the URLs behind the green “Code” button on your repository page. Once you have the one you want, you can use
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot. It appears that the first command sets the remote URL as the value for “url” in the [remote “origin”] section of the local .git/config file (which was already set when the local repo was cloned to GitHub), and the second one sets the value for “pushurl” in the same section. However, when running “git push”, I still get asked for the GitHub username and password, despite having SSH keys set up and tested. As such, the question is whether there is a way to set up the local computer so that I can simply “git push” without entering any additional credentials? If not, what is the SOP for “git push” to the GitHub repository then? Thanks for any hint. |
Beta Was this translation helpful? Give feedback.
-
Hi @balabin It not, it sounds like your configuration is wrong, there are excellent step by step instructions in GitHub docs that can be followed, on previous experience working with other users problems following these explicitly has worked for them. If you still experience issues it will help anyone assist you in further problem analysis |
Beta Was this translation helpful? Give feedback.
-
Hi @byrneh, Indeed, the issue was having an HTTP URL in .git/config; changing it to the SSH URL made SSH keys work. Thanks for the documentation links, too; somehow, I overlooked the second one. Things are much more usable now - thanks a lot for your help! |
Beta Was this translation helpful? Give feedback.
-
Hi @balabin glad you are up and working as you want now. |
Beta Was this translation helpful? Give feedback.
-
Hi @byrneh, done - thanks for the hint. |
Beta Was this translation helpful? Give feedback.
-
so I wonder if it's correct that using the HTTPS method to push is banned so we can only use the SSH method now?@balabin |
Beta Was this translation helpful? Give feedback.
Hi @balabin
A common mistake is using the wrong URL, as this actually determines the authentication mechanism is used. So whether a local configured SSH key is used, or a prompt for username/token or their local credential manager cached values.
You can only push to two types of URL addresses:
An HTTPS URL like https://github.com/user/repo.git
An SSH URL, like git@github.com:user/repo.git
I cannot see from your question what URL format you have used, but worth checking.
It not, it sounds like your configuration is wrong, there are excellent step by step instructions in GitHub docs that can be followed, on previous experience working with other users problems following these explicitly has…