%% Last Updated: - [[2021-02-09]] - [[2020-12-08]] %% ## Create a new SSH key `ssh-keygen -t rsa -C "your-email-address"` where the email address is the one that belongs to the second [[GitHub]] account The default one is `id_rsa` and you do NOT want to use that. Instead, use something different like `id_rsa_PERSONAL` or `id_rsa_COMPANY`. The SSH key will be saved in `~/.ssh` ## Attach a new key Sign into GitHub and create a new key: Settings > SSH Public Keys > New Key. In Finder, open `~/.ssh/id_rsa_PERSONAL` or whatever you called it, and copy the entire string there. Paste the string into GitHub and save it. In the Terminal, type: `ssh-add ~/.ssh/id_rsa_PERSONAL`. You should get the response `Identity Added`. ## Create a config file Create a config file in `~/.ssh/` if there isn't one already. Add this to the file: ```bash [[Default]] GitHub Host github.com HostName github.com User git IdentityFile ~/.ssh/id_rsa Host github-PERSONAL HostName github.com User git IdentityFile ~/.ssh/id_rsa_PERSONAL ``` ## When you set the origin, specify the secondary account Initialize or go to the repository you want to push to the second account. `git remote add origin git@github-NVDH:nicolevanderhoeven/nicolevanderhoeven.github.io.git` You might have to remove the current origin if you already have one. You should then be able to push to it! ## References - https://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574 - https://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer ## See also - [[Working with remotes in Git]] - [[Git]]