Git 克隆私有仓库,权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14028237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:55:47  来源:igfitidea点击:

Git clone private repo, permission denied

gitsshrepositorycloneprivate

提问by user1071182

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.

我正在尝试克隆另一个开发人员拥有的私有存储库。我与此开发人员没有直接联系。他们给我发送了一个 theirusername-id_rsa.pub 文件和一个 theirusername-priv.key.ppk 文件。我知道 ppk 文件特定于 Putty ssh 客户端。有人可以向我提供有关如何克隆他们的 repo 的步骤吗?我已经用我自己的帐户配置了 git,我想我必须将他们的 ssh 密钥添加到我的 ssh/config 文件或其他东西中,但我有点像 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

编辑:我能够访问 github 存储库并将自己添加为合作者。即使在这样做之后我也不能

git clone [email protected]:theirusername/pro.git

however

然而

git clone https://github.com/theirusername/pro.git

did work.

没有工作。

回答by poke

They sent me a theirusername-id_rsa.pub file and a theirusername-priv.key.ppk

他们给我发送了一个 theirusername-id_rsa.pub 文件和一个 theirusername-priv.key.ppk

First of all, tell them to neverdo 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 yourkey to their own profile. I'm emphasizing on “your key”, as youshould 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 pageantto load the key file and make Git use PuTTY's plinkas the SSH client. You can do that by setting the GIT_SSHenvironment variable to the path to plink.exe, e.g. C:\Program Files\PuTTY\plink.exe.

话虽如此,当您拥有 PPK、PuTTY 私钥文件时,您有两种选择。首先是使用 PuTTY 的pageant加载密钥文件并使 Git 使用 PuTTY 的plink作为 SSH 客户端。您可以通过将GIT_SSH环境变量设置为 的路径来做到这一点plink.exe,例如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_rsato make Git use it.

第二种选择是将 PPK 转换为 Git 附带的 SSH 客户端可以使用的 OpenSSH 密钥文件。您可以通过使用 PuTTYgen 打开 PPK 并选择“Conversions/Export OpenSSH key”来实现。您应该将文件另存为C:\Users\<username>\.ssh\id_rsa让 Git 使用它。

回答by VonC

You need:

你需要:

回答by kki

Just copy and paste below code in a bat file and execute it

只需将下面的代码复制并粘贴到 bat 文件中并执行它

echo y|"C:\Program Files (x86)\PuTTY\plink.exe" [email protected] -pw XXXX exit

echo y|"C:\Program Files (x86)\PuTTY\plink.exe" [email protected] -pw XXXX exit

XXX.XXX.XXX.XXX : This is IP Address of your device.

XXX.XXX.XXX.XXX :这是您设备的 IP 地址。

XXX : This is password of your device

XXX:这是您设备的密码