Reputation: 577
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
Upvotes: 17
Views: 24815
Reputation: 1323095
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.
Upvotes: 45