gitlab: Windows: How to use chmod and fix "Get Permission denied (publickey). fatal: Could not read from remote repository"

peterc

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

  1. Am I on the right track here, is it the permissions of the folder/files that are the problem
  2. 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!

VonC

Am I on the right track here, is it the permissions of the folder/files that are the problem

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:

Copy-paste the key (id_rsa.pub content) to the 'My SSH Keys' section under the 'SSH' tab in your user profile. Please copy the complete key starting with ssh- and ending with your username and host.

Secondly, ssh will locally look for the private and public keys in %HOME%.
And %HOME% isn't defined by default in Git, unless you launch git-cmd.exe or git-bash.exe packaged with the latest Git for Windows 2.4.x+.

So:

  • make sure to grep PortableGit-2.4.3.1-2nd-release-candidate-64-bit.7z.exe, and unzip it anywhere you want (for example in: c:\prgs\git\PortableGit-2.4.3.1-2nd-release-candidate-64-bit)
    Don't intall the old obsolete msysgit 1.9.5 from git-scm.com. As I explained, it will soon be phased out.
  • add c:\prgs\git\PortableGit-2.4.3.1-2nd-release-candidate-64-bit\usr\bin to your %PATH% (it includes ssh.exe)
  • launch 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>)
  • generate your ssh keys (or copy your existing one in %HOME%\.ssh). Don't worry about chmod or rights.
  • make sure your ssh public key is copied in your GitLab ssh key page.

Then, test if ssh works:

ssh -Tv [email protected]

Now you can start pushing.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to chmod +x a file in Windows, for use in Linux?

From Dev

How to fix sudo after "chmod -R 777 /usr/bin"?

From Dev

How to fix sudo after “chmod -R 777 /etc/”?

From Dev

How to use git flow in GitLab

From Dev

How do I use 'chmod' on an NTFS (or FAT32) partition?

From Dev

How to fix the MBR for Windows 7?

From Dev

How to fix the MBR for Windows 7?

From Dev

How to fix icons in Windows 10

From Dev

chmod equivalent for windows

From Dev

Chmod 777 in Windows 7

From Dev

How to use a SecureSocket to fix a HandshakeException?

From Dev

How to use a SecureSocket to fix a HandshakeException?

From Dev

How to fix port 52493 is in use

From Dev

Use chmod command selectively

From Dev

How to Fix Billing Warning When Connecting GitLab to New GKE Cluster

From Dev

How to use GitLab and Gitlab-Mattermost on one machine?

From Dev

gitlab 8.2.1, How to use cache in .gitlab-ci.yml

From Dev

how to use web hooks on Buildbot (gitlab integration)

From Dev

How to configure gitlab to use existing postgres server

From Dev

How to use Go with a private GitLab repo

From Dev

How to use issues of Gitlab from terminal?

From Dev

How to use cache for a rails project in Gitlab CI?

From Dev

how to use web hooks on Buildbot (gitlab integration)

From Dev

how i can use submodule gitlab in this stracture

From Dev

Fix permissions of server after accidental chmod debian

From Dev

Fix permissions of server after accidental chmod

From Dev

How to chmod only on subdirectories?

From Dev

Windows 8.1 How to fix this obsolete code?

From Dev

How to fix 'cordova' is not recognized in the Windows command prompt

Related Related

HotTag

Archive