I have gone through many other posts about the above error, but they all seem to be for a different OS, or for some different reason.
I am running Windows 8.1. I have git installed (I am very new to git), and have signed up to gitlab, create a project there, created and added the key (as per instructions), however when I try and do a push, I get the
Pushing to [email protected]:myusername/Test1.git
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Now when I created my ssh key using
ssh-keygen -t rsa -C "[email protected]
it did create the files in the local project folder, and not under C:\Users\Peter (my home folder)
So, copied the single file (known_hosts) I deleted the existing .ssh folder, and created using bash, and then copied in the above together with the created id_rsa.pub and idrsa.key files.
From Git Gui, if I go to Help | Show SSH Key is reports "Found a public key in ~/.ssh/id_ras.pub
From bash, my permissions on the folder are.
drwxr-xr-x 1 Peter Administ 0 Jun 14 09:35 .ssh
and the permissions on the files within are..
$ ls .ssh -l
total 2
-rw-r--r-- 1 Peter Administ 403 Jun 13 18:26 id_rsa.pub
-rw-r--r-- 1 Peter Administ 1766 Jun 13 18:26 idrsa.key
-rw-r--r-- 1 Peter Administ 184 Jun 13 18:11 known_hosts
I am assuming I need to fix the permissions here?
So I go into the .ssh folder and try a chmod 777 *
But then when I use ls -l to see the permissions they have not changed
Likewise when I try that on the actual directory .ssh, permissions stay as they are
So, the questions are
- Am I on the right track here, is it the permissions of the folder/files that are the problem
- If so, how can I fix this (on Windows 8.1)
I am at a complete loss of what to try next
Thanks in advance for any help!
Not really: "permission denied" is sent back by the GitLab server, as it doesn't recognize your ssh public key.
Firstly, as mentioned in GitLab ssh keys doc page:
Secondly, ssh will locally look for the private and public keys in
%HOME%
.And
%HOME%
isn't defined by default in Git, unless you launchgit-cmd.exe
orgit-bash.exe
packaged with the latest Git for Windows 2.4.x+.So:
Don't intall the old obsolete msysgit 1.9.5 from git-scm.com. As I explained, it will soon be phased out.
c:\prgs\git\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin
to your %PATH% (it includesssh.exe
)c:\prgs\git\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\git-cmd.exe
, and see that%HOME%
is define (set HOME
).It should be defined to your
%USERPROFILE%
by default (c:\Users\<yourLogin>
)%HOME%\.ssh
). Don't worry about chmod or rights.Then, test if ssh works:
Now you can start pushing.