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.
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.
"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 (.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With