Skip to content

Instantly share code, notes, and snippets.

@GitAlison
Created April 22, 2022 22:50
Show Gist options
  • Save GitAlison/335852905fda2511a27aa53ba9c76583 to your computer and use it in GitHub Desktop.
Save GitAlison/335852905fda2511a27aa53ba9c76583 to your computer and use it in GitHub Desktop.
# Create keys
cd .ssh/
# Generate SSH key for each GitHub account
ssh-keygen -t rsa -C "your_name@email.com"
ssh-keygen -t rsa -C "your_name@work.com"
~/.ssh/id_rsa_personal
~/.ssh/id_rsa_work
$ ssh-add ~/.ssh/id_rsa_activehacker
$ ssh-add ~/.ssh/id_rsa_jexchan
# Configure users
$ git config user.name "work"
$ git config user.email "work@gmail.com"
$ git config user.name "personal"
$ git config user.email "personal@gmail.com"
Add you reference keys
Create file in ~/.ssh/config
#Personal account
Host github.com-peronal
HostName github.com
User git
IdentityFile ~/.ssh/personal
#Work account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/work
#Clone example
git clone git@github.com-personal:personal/repository.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment