mdx
mdx

Reputation: 534

Github SSH access: Permission denied (publickey)

I've recently set up a git repository on Win10 via Cygwin and now I'm trying to make it track a remote repo on github.

The problem is, that after adding a remote like this:

 git remote add github-remote [email protected]:username/github-remote.git

I cannot access it in any possible way (pushing, fetching, displaying additinal info by 'show'). All I get is this:

[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.

Although I know this topic's been discussed a lot, none of the solutions I found actually helped. That's why I decided to post yet another question.

Here's what I did, step-by-step:

1) Generated the pub-priv keypair:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Tried with both - a default and a custom directory for the id_rsa files. Same results.

2) Ran the ssh agent (or checked for it running, to be precise):

eval $(ssh-agent -s)

3) Added the key to the agent

ssh-add ~/.ssh/id_rsa

4) Copied the id_rsa.pub to github

5) Checked if the connection's set properly

ssh -T [email protected]

... with a promising result of

You've successfully authenticated, but GitHub does not provide shell access.

From what I learned this error may be due to git's address not being included in the /.ssh/known_hosts file. The thing is (as far as I know) that it is being inserted automatically e.g. with 'ssh -T' so I doubt it's the case, either. Although tried that as well:

ssh-keyscan -t rsa github.com | ssh-keygen -lf -

Another possible problem could be my private key's access being available too widely for the users, but I checked that, too.

With all that said I have no further idea how to fix this one, so I'd appreciate any help. Thank you in advance.

Upvotes: 3

Views: 2373

Answers (1)

Schwern
Schwern

Reputation: 164629

As for git, I downloaded the .exe from git-scm.com/download/win. SSH on the other hand I had to install as a Cygwin's package, and it's Cygwin's mintty in which I run all of the commands...

Mixing Cygwin and Git For Windows is likely the problem. While I'm sure there's a way to make them work, it's simplest to stick to one or the other.

Git For Windows comes with its own "Git Bash" shell and, I believe, ssh. Use that.

Or, if you want to stick with Cygwin, get Git from from Cygwin and use that.

Running Git through Cygwin from Windows might also be useful.

Upvotes: 2

Related Questions