Forums

SSH connection to Github authentication fails

Hi All, After struggling for hours, I come to you for help. (I have a paid account, so I expect SSH to work) I have created my public and private SSH keys, added the public key to Github, and ran the script to link it.

18:21 ~/mysite (master)$ eval "$(ssh-agent -s)"
Agent pid 442
18:24 ~/mysite (master)$ ssh-add ~/.ssh/id_rsa
Identity added: /home/pegasus163/.ssh/id_rsa (michael-gill-ba@outlook.com)

But, whenever I try to clone, etc. I am asked to log in. I do so and it fails:

19:12 ~/mysite (master)$ git remote show origin
Username for 'https://github.com': michael-gill-ba@outlook.com
Password for 'https://michael-gill-ba@outlook.com@github.com': 
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pegasusdba/tradingbot.git/'

I have changed my password to ensure I'm not making a mistake, but it still fails. Please advise.

It looks like the repository you're working in has its origin set up to be HTTPS rather than SSH, so the ssh-add command you're using won't affect it. If you want to stick with HTTPS then you would need to create an access token (as described by the GitHub help page linked in the error message), but if you want to switch to SSH instead, you could use git remote remove origin to remove the existing HTTPS-based one, and then git remote add origin SSH_REPO_URL to add the SSH-based one (replacing SSH_REPO_URL with the actual URL, of course).

Thanks Giles. I just noticed that the Github site offers different addresses, based upon the tab selected. I never noticed that and had copied the HTTPS rather than SSH address.

Thanks

No problem, glad to help -- is it all working OK now?

Yes, thanks. Pushing, pulling, etc.

Excellent, thanks for confirming!

I just want to say this advice has been great for me as well, thanks Giles!

Glad to hear that!