简体   繁体   English

git 克隆加载错误的 SSH 密钥 (Windows)

[英]git clone loads wrong SSH-Key (Windows)

I was invited to a company project on github and I'm trying to clone the project.我受邀参加 github 的公司项目,我正在尝试克隆该项目。 But another email/github account was invited to that project.但是另一个电子邮件/github 帐户被邀请到该项目。 Now when I'm trying to clone the project, I get the following output:现在,当我尝试克隆该项目时,我得到以下 output:

git clone git@github.com:XXX/YYY.git .      
Cloning into '.'...
load pubkey "/c/Users/XXX/.ssh/id_rsa": invalid format
Load key "/c/Users/XXX/.ssh/id_rsa": invalid format
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.      

Please make sure you have the correct access rights

I created before a new rsa key.我之前创建了一个新的 rsa 密钥。 The file is called: id_rsa_xxx & id_rsa_xxx.pub and added the pub rsa key to my second github account.该文件名为: id_rsa_xxx & id_rsa_xxx.pub并将 pub rsa 密钥添加到我的第二个 github 帐户。

But as you can see in my console output, my console is loading the public and private key named: id_rsa and not id_rsa_xxx但是正如您在我的控制台 output 中看到的那样,我的控制台正在加载名为: id_rsa而不是id_rsa_xxx的公钥和私钥

And I have no clue how to change it just for this project.而且我不知道如何仅为这个项目更改它。 For all my other projects, the id_rsa file is the right one.对于我所有的其他项目, id_rsa文件是正确的。

I also added the id_rsa_xxx with " ssh-add " by using the " ssh-agent " before.我还通过使用“ ssh-agent ”之前使用“ ssh-add ”添加了id_rsa_xxx

Any clue?有什么线索吗? I mostly find mac OS answers but nothing so far that helped me for windows. I also don't have a "config" file inside the.ssh folder.我主要找到 mac OS 的答案,但到目前为止对 windows 没有任何帮助。我在 .ssh 文件夹中也没有“配置”文件。

As torek already mentioned, you can create a new entry in your ~/.ssh/config file , which could look something like this:正如 torek 已经提到的,您可以在~/.ssh/config 文件中创建一个新条目,它看起来像这样:

Host your_preffered_name_here
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_xxx

Next try again: git clone your_preffered_name_here:XXX/YYY.git接下来再试一次: git clone your_preffered_name_here:XXX/YYY.git

PS: I'm not sure if the User git option is really required PS:我不确定是否真的需要用户 git选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM