6

So I have my public ssh key added to the git repo. I have the private key added to my /c/Users/totty/.ssh/.

When I run ssh -vT git@github.com it says Hi X! You've successfully authenticated, but GitHub does not provide shell access.

When I run git push origin I get Permission to * denied fatal: Could not read from remote repository

What is wrong with this github? I can't push from cmd, git extensions. But it works from github from windows...

After I remove my ssh keys and run ssh -vT git@github.com I get debug1: No more authentication methods to try..


Also another thing that is strange... if you look at the circled text, that's not my username or email anywhere. I even check in my git config and is nowhere. Where is coming from? I mean gs11118

enter image description here

Totty.js
  • 15,563
  • 31
  • 103
  • 175

2 Answers2

2

First, the username/email (the one you set with git config user.name / user.email) has nothing to do with GitHub credentials (a user GitHub account name)

Second, make sure your git push is actually using an SSH URL:

cd /path/to/my/local/repo
git remote -v

If you see an URL staring with https://..., it won't matter that ssh -T git@github.com does identifies you correctly: Git would not use that as credentials. It would use what is stored in the Windows Credentials Manager.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
-1

You may pushing to a repo that is not belonging to you or owned by you, which is cloned from others.

The repository's URL (which can be shown by git remote -v) with SSH format is like this:

origin  git@github.com:username/repo.git(fetch)
origin  git@github.com:username/repo.git(push)

or HTTPS format:

origin  https://github.com/username/repo.git(fetch)
origin  https://github.com/username/repo.git(push)

In your repository, you may found that the username is not yours, neither your organizations nor your collaborators. Then, if you want to push that, you may come to the original repository (https://github.com/username/repo), to fork that repo into your GitHub account (as the question's github tag), then use git remote set-url origin command to rewrite the local repo's remote URL.

After that, you can push it to the remote, which is owned by you, as a fork to others. EDIT: if you are using HTTPS way, you may take a look at Git Credentials

Or, if the origin repository is where you are responsible for developing, you may request the organization or collaborators to add you as a collaborator.

EDIT2: Thanks to the comment (talk?) with @VonC, you may look at the file ~/.ssh/config, which may be C:\Users\totty\.ssh\config due to the image you given, to find whether there is a specified key, an IdentityFile, for this repo. Reference: Specify an SSH key for git push for a given domain

Geno Chen
  • 4,916
  • 6
  • 21
  • 39
  • No: the remote repo does not matters. What matters (in a red circle in the OP's picture) is the username GitHub uses for authenticating to that remote repository (owned or not): that username is *not* the one expected. My answer indicates where to look for that unexpected username. Once the username used is the right one, then and only then yes: your answer would apply. – VonC Jun 23 '18 at 07:30
  • @VonC I tried pushing to other's repository using SSH way, the error is 'Permission to /.git denied to .', and using HTTPS way will have a more error 'fatal: unable to access 'https://github.com//.git/': The requested URL returned error: 403'. However the OP doesn't got the error message of HTTPS, and doesn't know who the 'me' ([gs11118](https://github.com/gs11119)) is. Is there any possibility that **this repo** is using gs11118's SSH Key by mistake? – Geno Chen Jun 23 '18 at 07:52
  • Possible yes: it really depends on the actual URL used for 'origin'. Regarding ssh, it the remote URL) could refer to an entry in `~/.ssh/config`, which would reference the wrong private key. – VonC Jun 23 '18 at 07:54
  • @VonC Thank you. I added my answer with something looks like related. – Geno Chen Jun 23 '18 at 08:07
  • This is not an actual answer and the person answering does not seem to fully understand what the problem is. – mibbit Oct 13 '18 at 00:12