简体   繁体   中英

Unable to Git clone with a second personal github account

I have added a second github account on my laptop in addition to the first one. The document https://betterprogramming.pub/how-to-use-multiple-github-accounts-with-one-computer-c9ba3f851b75 did help a lot but I am facing issues while cloning a repo which is accessible from the second github account.

I generated the keys id_rsa_unaccount and id_rsa_unaccount.pub and added the content of id_rsa_unaccount.pub to my ssh field in the second github account.

>ls ~/.ssh  
config          id_rsa          id_rsa.pub      id_rsa_unaccount    id_rsa_unaccount.pub

Updated the ~/.ssh/config

# Account 1 (work or personal) - the default config
Host github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa

# Account 2 (personal) - the config we are adding
Host github-unaccount
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_unaccount

Also setup

git config user.name "Gupastha" 
git config user.email "asthagupta92+8@gmail.com"

However when I tried to git clone the repo, I see

git clone git@github-unaccount:Noble-Missions/itakeactions.git 
Cloning into 'itakeactions'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

I also went through multiple stack overflow links for the same but I couldnt find a solution to the cloning yet. Can anyone please nudge me?

Check first if your second key is recognized:

ssh -Tv github-unaccount

No need for git@ since it is included in your ~/.ssh/config

Then use, assuming Linux-like environment:

export GIT_SSH_COMMAND='ssh -v'
git clone github-unaccount:Noble-Missions/itakeactions.git 

You will see what keys are considered during the clone operation.

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