0% found this document useful (0 votes)
28 views2 pages

Github SSH Workflow

GitHub SSH workflow - or, how to setup multiple SSH users on git
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Github SSH Workflow

GitHub SSH workflow - or, how to setup multiple SSH users on git
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Multi-Account GitHub SSH Workflow -

seamless push-pull from different accounts


without credential drama!

Step-by-Step: Multi-GitHub SSH Setup


Let’s say:

You have two GitHub accounts:

personal-account
work-account (or whichever was added as a collaborator)

You want to keep separate SSH keys for each.

1. Generate a New SSH Key for the Second GitHub Account

ssh-keygen -t ed25519 -C "[email protected]"

When prompted to save the key, give it a unique name (e.g., id_ed25519_work ):

Enter file in which to save the key: /Users/you/.ssh/id_ed25519_work

Now you have:

Private key: ~/.ssh/id_ed25519_work


Public key: ~/.ssh/id_ed25519_work.pub

2. Add That SSH Key to Your GitHub Account


Copy the public key:

pbcopy < ~/.ssh/id_ed25519_work.pub # macOS


# or
cat ~/.ssh/id_ed25519_work.pub # then copy manually

Go to GitHub → Settings → SSH and GPG Keys → New SSH key

Add it to the account that has repo access (the one added as a collaborator).

3. Create a ~/.ssh/config File


This lets you specify which key to use for which GitHub account.

Edit or create the config:

vim ~/.ssh/config

Then add this:


# Personal GitHub
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519

# Work GitHub
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work

Adjust the paths if your key files are named differently.

4. Clone the Repo Using the Matching Host Alias


Instead of cloning from [email protected]:... , you use your custom host:

git clone git@github-work:user/reponame.git

That github-work alias makes Git use the correct SSH key behind the scenes.

5. Push and Pull with No Issues


Once it’s cloned like that, Git will always use the right key — and you can have both
personal and work accounts happily coexist.

Bonus: Using Multiple Git Emails per Repo


If your Git author email is different for each account, you can configure per-repo
email:

cd reponame
git config user.name "Ishaan Shrivastava"
git config user.email "[email protected]"

You might also like