It depends on the remote URL you used.
If git remote -v returns:
https:
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.
Vonc
source share