Github authentication error even after adding SSH key

I get fatal: an authentication error when I try to push the code to my repo. I also added the public key to my github account. When I do: ssh -i git@github.com
I get Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access. Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.

Can anyone help? Thanks

+5
github ssh
source share
1 answer

It depends on the remote URL you used.

If git remote -v returns:

 https://github.com/username/reponame 

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

 ssh:// git@github.com :username/reponame 

Another reason is related to your private key: if it is password protected, with a special character that usually does not work.
See here for other reasons for ssh failure .


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

 git remote set-url origin ssh:// git@github.com :username/reponame 

(as explained in the GitHub help page about changing 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 using ssh syntax without scp:

 git remote set-url origin ssh:// git@github.com /username/reponame 

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

Perhaps this would work, as commented on this blog post :

 git remote set-url origin git@github.com :username/reponame 

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

As I mention here , scp syntax usually means that the ~/.ssh/config file is working correctly.

+18
source share

All Articles