Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication Failure on Github even after adding SSH key

Tags:

github

ssh

I get fatal:Authenication Failure when I try to push code to my repo. I've added the public key on my github account as well. When I do : ssh -i [email protected]
I get Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.

Can anyone help? Thanks

like image 801
Aman Gupta Avatar asked Jul 10 '13 20:07

Aman Gupta


People also ask

How do I fix authentication failed on GitHub?

The “fatal: Authentication failed” error message Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

How do I enable SSH key authentication in GitHub?

At present, you can only use GitHub CLI to add SSH authentication keys, you cannot add SSH signing keys. To add an SSH authentication key to your GitHub account, use the ssh-key add subcommand, specifying your public key. To include a title for the new key, use the -t or --title flag.

Why is my SSH key not working?

Here are some steps you can take to troubleshoot this issue: Make sure the authorized_keys file and the private key itself have the correct permissions and ownership. Check that key-based authentication is allowed by the server. Make sure the private key is readable by the SSH client.


1 Answers

That depends on the remote url you have used.

If git remote -v returns:

https://github.com/username/reponame

Then your ssh setup won't matter. But this would work:

ssh://[email protected]:username/reponame

Another cause is linked to your private key: if it is pass-phrase protected, with a special character in it, that usually don't work well.
See here for other ssh causes of failure.


To replace your remote named origin, use git remote commands:

git remote set-url origin ssh://[email protected]:username/reponame

(as explained in the GitHub help page about changing the rmeote url)

If you see::

ssh: Could not resolve hostname github.com:amangupta052: 
     Name or service not known 
fatal: The remote end hung up unexpectedly

Try the non-scp ssh syntax:

git remote set-url origin ssh://[email protected]/username/reponame

(note the '/' instead of the ':' after github.com)

Maybe this would have worked, as commented in this blog post:

git remote set-url origin [email protected]:username/reponame

(scp-like syntax, but without the ssh:// prefix)

As I mention here, an scp syntax usually means an ~/.ssh/config file to work properly.

like image 194
VonC Avatar answered Sep 30 '22 10:09

VonC