- Create new key
ssh-keygen rsa -C "email address for account"
- Don't overwrite your keys. Give each key its own name. For example
id_rsa_Account1
andid_rsa_Account2
. Or just give your primary account id_rsa and name the other accounts accordingly. - Attach the new key.
- Open the
id_rsa_AccountName.pub
file. Copy the string from that file. - Login to GitHub
- Click Settings (top right)
- Click the SSH keys link (left hand nav)
- Click the "Add SSH key" button
- Provide title like "home computer"
- Paste string into "key" field
- Open the
- Create a config file
touch ~/.ssh/config
subl ~/.ssh/config
- Create 2 entries, the first should entry is your default github account and the second should be your secondary account. The config file should look something like this:
#Default Account
Host github.com
HostName github.com
User [username1]
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
#Secondary Account
Host github-SECONDARY
HostName github.com
User [username2]
IdentityFile ~/.ssh/id_rsa_Account2
IdentitiesOnly yes
Make sure you add the IdentitiesOnly yes
. This is neccessary to make sure that you don't log into a GitHub account and get "stuck" with it.
To add remote repository using that secondary account
git remote add origin git@github-SECONDARY:account2/repoName.github.io.git