Search code examples
githubsshgit-remote

GitHub not letting to push after resetting keys triple times, based on their tutorial, based on bitbucket tutorial, still denied


banana@banana-pc:~/Projects/bananaproject$ git remote add origin https://github.com/bananauser/bananaprojectmanager.git
error: remote origin already exists.
banana@banana-pc:~/Projects/bananaproject$ git push -u origin main
Username for 'https://github.com': ^C
banana@banana-pc:~/Projects/bananaproject$ ssh -T [email protected]
Hi bananauser! You've successfully authenticated, but GitHub does not provide shell access.
banana@banana-pc:~/Projects/bananaproject$

How can I be authenticated and not being able to push?

  • I added my public key to my profile settings "SSH and GPG KEYS".
  • I added my key to the ssh agent.
  • I am authenticated based on ssh -T [email protected]
  • I am just trying to initialise new repository and make a first push.

Note that on ssh -T [email protected] it also gives me correct github account name which is totally dissimilar to everything I have named on my pc.

JC.


Solution

  • It asked you to supply your username for https://github.com when pushing, so your remote was set to use HTTPS, https://github.com/bananauser/bananaprojectmanager.git, rather than what would be the SSH remote for that repository, [email protected]:bananauser/bananaprojectmanager.git.

    It would have been possible to fix with;

    git remote set-url origin [email protected]:bananauser/bananaprojectmanager.git
    

    While the remote (see git remote -v to check it) was set to HTTPS, your SSH authentication wouldn't have mattered. Worth noting as well that verifying SSH authentication in that manner just verifies that the first successful try for a key that is set to be attempted for that host is an authenticated key for some user, not necessarily the owner of a repository, a detail which is important to keep in mind if you have multiple accounts and you're trying to verify a specific one, you need to make sure the key for that account it the first key it will attempt for github.com.