Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cygwin ssh key added, but Git permission denied (publickey)

I have a problem when trying to use Git with Cygwin. I've generated and added ssh key to the GitLab server and everything works just fine through the MINGW64 (cloning, pulling, etc), but I wanted to use Cygwin and found that it doesn't work.

Though I've put copy of my generated key to the ~/user/.ssh folder and manually added key, so "ssh-add -l" prints it in the list, but when I try to fetch repository (or any other server command) I just get:

Permission denied (publickey).
fatal: Could not read from remote repository.

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

It looks like a bug, but possibly I'm doing something wrong. Did anyone get this problem? Thank you.

UPDATE: After updating OpenSSH version in Cygwin described problem has gone.

like image 366
mmelnik Avatar asked Feb 18 '16 12:02

mmelnik


People also ask

How do I fix git permission denied?

Confirm that your public key has been configured correctly by checking the SSH and GPG link in your account settings. If no keys are listed, add your public key and try to connect to GitHub over SSH again. The error should go away.

Why do I get permission denied Publickey?

"Permission denied (publickey)" and "Authentication failed, permission denied" errors occur if: You're trying to connect using the wrong user name for your AMI. The file permissions within the operating system are incorrect on the instance. The incorrect SSH public key (.

How do I fix error permission denied Publickey fatal could not read from remote repository GitHub?

The “Permission denied (publickey). fatal: Could not read from remote repository” error is caused by an issue with the way in which you authenticate with a Git repository. To solve this error, make sure your key is being used on your Git account. If it is not, add your key to Git.

How do I give permission to clone a git repository?

Open Security for a repository To choose another project, see Switch project, repository, team. Open Project settings>Repositories. To set the permissions for all Git repositories, choose Security. For example, here we choose (1) Project settings, (2) Repositories, and then (3) Security.


1 Answers

For me, the cause is that I put my ssh key files in C:\Users\username\.ssh (which is /cygdrive/c/Users/username/.ssh in cygwin), but actually, you need to put your ssh keys in ~/.ssh to make it work. They are two different directories.

Run the following command in cygwin solved my problem.

cp /cygdrive/c/Users/username/.ssh/* ~/.ssh/

Notice that you should replace username with your actual one.

like image 101
Searene Avatar answered Oct 20 '22 14:10

Searene