I need to use my company GitHub from my local machine.
I prefer to use SSH.
I have a private GitHub account that is already using SSH with the local default key (~/.ssh/id_rsa.pub).
I use Windows.
I'm logged in with my company account and I can see the repositories.
If I do git clone <git url>
or git clone <https url>
I receive: "repository not found".
With git -T git@github.com
I see that I'm autenticated with my personal GitHub account.
I tried to regiter the local default SSH key (id_rsa.pub) on the company GitHub account but it says the key is already in use (I imagine it refers to my personal account).
I registered another key (id_rsa_test.pub) but I can't find any parameter in git to pass a different key/credentials?
How can I use git, with SSH, from my local PC without replacing my personal SSH key with a specific SSH key?
As a temporary solution I tried to put this in the GIT config, but does not work (still "Repository not found" error)
Host GitHub
HostName github.com
User alex-company-user
IdentityFile c:\Users\alex\.ssh\new_key_rsa
ssh-add <path to the new key file>
returns "Error connecting to agent: No such file or directory"
I think because on this machine I don't have Git-Bash installed.
(as I understood it is practically mandatory to have a up and running ssh-agent all the time?)
GIT_SSH_COMMAND='ssh -i C:\Users\alex\.ssh\new_key_rsa'
returns "'GIT_SSH_COMMAND' is not recognized as an internal or external command"
[Temporary solution: GitHub Desktop]
As a temporary solution I'm usaing GitHub Desktop.
It ALWAYS authenticate with the browser (also after you passed the user/password and entered the verification code received by SMS !!) and it ALWAYS use the alredy logged in user in the browser.
So, I enter the username and password of my company account, click "sign in", receive the SMS with the verification code, OK. It says I have to authenticate with the browser, click "continue"... it opens the browser and I'm automatically authenticated with my personal account!
So, I have to log out on the browser from my personal account, repeat the procedure after been logged in with my company account in the browser.
(I opened an Issue for this)
It lets me choose the repository to clone from a list. I cloned it and I found it is using the HTTPS URL (repo/.git//config):
[remote "origin"]
url = https://github.com/<my-company-repo>.git
(maybe I can change this to the SSH, I'll try) So, I hope this solution does not require me to switch the user in the browser often. I still like to know how to do it using git directly (without a 3rd party tool).