-1

I have two github accounts, one for work and one persona, both hosted in github.com without a subdomain. I would like to configure ~/.ssh/config based on repo owner for my work account all repos are under lets say github.com/company_name/repo_name and my projects are on github.com/my_persona_user/repo_name.

Thanks in advice for your help

Manolo
  • 125
  • 2
  • 10
  • https://stackoverflow.com/search?q=%5Bgit%5D+multiple+ssh+accounts – phd Jun 14 '22 at 16:44
  • I saw that FAQ, but I wanted to avoid the use of the Host in the remote and be able to use the default clone url provided by github. – Manolo Jun 14 '22 at 17:07

1 Answers1

0

Use your SSH config, as explained in the Git FAQ:

# This is your work account
Host work
    HostName github.com
    User git
    # This is the key pair registered for your work account
    IdentityFile ~/.ssh/id_work
    IdentitiesOnly yes
# This is the personnal account
Host perso
    HostName github.com
    User git
    # This is the key pair registered for your personal account
    IdentityFile ~/.ssh/id_perso
    IdentitiesOnly yes

Then in your personal clones:

git remote set-url origin git@perso:my_persona_user/repo_name.git

and in work clones:

git remote set-url origin git@work:company_name/repo_name.git
philb
  • 2,031
  • 15
  • 20
  • I saw that FAQ, but I wanted to avoid the use of the Host in the remote and be able to use the default clone url provided by github. – Manolo Jun 14 '22 at 17:06
  • OK, then maybe add that to your question since it makes it more precise :) – philb Jun 20 '22 at 18:27