AlexH
AlexH

Reputation: 1127

OpenSSH: [email protected] permission denied

I need to use PowerShell instead of WSL for one of my projects. I wanted to set up my terminal to use ssh instead of entering my credentials each time.

I've done this successfully in the past on WSL, but it seems OpenSSH is giving me trouble on PowerShell. When I try to perform a simple push command to a completely new repo, I'm given the following error:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Here's where things start getting weird... I've followed all of the steps outlined in GitHub's article on this very subject, and everything suggests that I'm good to go.

Here's what I've done:

  1. Checked to make sure ssh-agent is running. It is.

  2. Ran ssh -vT [email protected]. It's using port 22, and I get Hi [MyUsername]! You've successfully authenticated, but GitHub does not provide shell access. at the very end.

  3. Verified that ssh-add -l -E md5 does have the correct public key.

  4. Verified that the public key spit out by ssh-add above is the exact same as the one I've added to my GitHub account.

  5. Despite step 1, checked to make sure that my key was actually being found. Indeed, it is (second line):

...
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\aleks/.ssh/known_hosts:1
...

I'm honestly stumped and out of ideas. What's going on?

Upvotes: 2

Views: 1960

Answers (1)

VonC
VonC

Reputation: 1323115

Try and set GIT_SSH_COMMAND to ssh -v, and try your git push again.
Or through a config

git -c core.sshCommand="ssh -v" push

The output will allow you to check Git is looking at the right key.
Make sure your ssh-agent is started in your Powershell session

The OP AlexH confirms in the comments:

it was not using the right identity the first time around.
I think this had something to do with me having named my files something other than id_rsa and id_rsa.pub.
Renaming them allowed it to go through.

Upvotes: 2

Related Questions