Git clone private repo, permission denied
Solution 1
They sent me a theirusername-id_rsa.pub file and a theirusername-priv.key.ppk
First of all, tell them to never do this. The public/private keys are called like that for a reason. It’s against its point to have multiple instances (persons or computers) share the same key. You should use a separate key for every single one, to have a 1-to-1 association between them.
If they can’t add you as a collaborator (which would require a user account for yourself), then they should just add your key to their own profile. I’m emphasizing on “your key”, as you should generate it and send them only the public key. The private one should always remain secret to everybody else.
That being said, when you have a PPK, a PuTTY private key file, you have two options. First would be to use PuTTY’s pageant to load the key file and make Git use PuTTY’s plink as the SSH client. You can do that by setting the GIT_SSH
environment variable to the path to plink.exe
, e.g. C:\Program Files\PuTTY\plink.exe
.
The second option would be to convert the PPK to an OpenSSH key file which the SSH client that comes with Git can use. You can do that by opening the PPK with PuTTYgen and choosing “Conversions/Export OpenSSH key”. You should save the file as C:\Users\<username>\.ssh\id_rsa
to make Git use it.
Solution 2
You need:
- to make sure you have environment variable
HOME
defined (if you do your git operations from a git bash session, this should be defined for you even on Windows) - to convert your ppk keys into id_rsa and id_rsa.pub: see "How to I tell Git for Windows where to find my private RSA key?".
- define your config file or add your key to ssh agent, as described in "Specify private SSH-key to use when executing shell command".
user1071182
Updated on June 04, 2022Comments
-
user1071182 almost 2 years
I am trying to clone a private repository owned by another developer. I do not have direct communication with this developer. They sent me a theirusername-id_rsa.pub file and a theirusername-priv.key.ppk file. I understand the ppk file is specific to to Putty ssh client. Can someone provide me with steps on how to clone their repo? I already have git configured with my own account and I think I have to add their ssh key to my ssh/config file or something, but I'm a bit of an ssh noob.
git clone [email protected]:theirusername/pro.git Cloning into 'pro'... Permission denied (publickey). fatal: The remote end hung up unexpectedly
Edit: I was able to get access to the github repository and add myself as a collaborator. Even after doing so I couldn't
git clone [email protected]:theirusername/pro.git
however
git clone https://github.com/theirusername/pro.git
did work.
-
cppanda over 11 years
-
smichak over 11 yearsMaybe you should try ssh:// scheme - if you have the keys in place try: git clone ssh://[email protected]/absolute/path/to/repo.git/
-
Blender over 11 yearsWhy don't they just add you as a collaborator?
-
user1071182 over 11 years@Blender, I was given the files by a client. I do not have direct communication with the developer/owner of the github repo.
-
uday over 11 yearsInstead of cloning [email protected] version using the http:// version of that git repo.
-
Montre over 11 years@smichak The default scheme should be ssh.
-
-
Artem over 11 yearsAnd to be very sure that your client has legal permission to pass along his or her key and let you in if they are not the owner. Looks like trouble to me.
-
VonC over 11 years"never do this": I agree. I was answering the second part (which you do more precisely), but your reminder is useful. +1
-
SSG over 4 yearsVery important!!!!You should save the file as C:\Users\<username>\.ssh\id_rsa to make Git use it. "id_rsa". If you give any other name to your ssh file (which is what I was doing, IT WILL NOT WORK WITH GIT!!!)