简体   繁体   中英

git clone loads wrong SSH-Key (Windows)

I was invited to a company project on github and I'm trying to clone the project. But another email/github account was invited to that project. Now when I'm trying to clone the project, I get the following 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. The file is called: id_rsa_xxx & id_rsa_xxx.pub and added the pub rsa key to my second github account.

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

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.

I also added the id_rsa_xxx with " ssh-add " by using the " ssh-agent " before.

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.

As torek already mentioned, you can create a new entry in your ~/.ssh/config file , which could look something like this:

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

PS: I'm not sure if the User git option is really required

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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