Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account?

I want to work on my personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account .

In my case , I will not be able to add my personal GitHub account as a collaborator for "Work" account's project . I was thinking I can add a new key pair on my office computer , and add it to my personal GitHub account . But will I be able to work on both "Work" and "Personal" repos seamlessly that way ? What's the best way to do this ?

like image 426
Emil Avatar asked Feb 20 '23 10:02

Emil


1 Answers

You can add as many public:private key you want, the idea being to register them in %HOME%/.ssh/config file, in order for you to define remote with ssh addresses like:

workgh:Work
persgh:Personal

See "change github account mac command line" as an example of an ssh/config file.

In your case:

#Personal GitHub
Host persgh
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_perso

#Personal Work
Host workgh
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_work

Reusing the same ssh key in different environment is genrally frowned upon.
See this SO question to generate multiple ssh keys non-interactively.

like image 109
VonC Avatar answered Feb 21 '23 22:02

VonC