17

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

1 Answer 1

45

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.

Sign up to request clarification or add additional context in comments.

10 Comments

Ok so my origin is https one, how can I get the ssh origin? I'm sorry I'm really new to git.
@AmanGupta no problem, I have edited my answer. Replace 'username' and 'reponame' by the appropriate values.
Ok, I set the new origin. I get ssh on doing git remote -v. But now, I get ssh: Could not resolve hostname github.com:amangupta052: Name or service not known fatal: The remote end hung up unexpectedly on doing git push
@AmanGupta is that the output of the git remote set-url command, or of the git push you could do just after?
i've set up SSH key and agent in my laptop and the connection to github was working properly but i still received the authentication error msg when using git push. Using your method ssh://[email protected]:username/reponame and replacing ':' with a slash worked for me.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.