Cover Image

How to manage multiple Git accounts on one computer using SSH config

Problem Statement

Why will i have multiple Git accounts?

Ideal Solution

Generate SSH Key pairs

$ ssh-keygen -t rsa -b 4096 -C ""
Adding SSh key to Github account
Adding personal SSH key to Github
$ ssh-keygen -t rsa -b 4096 -C ""

Use SSH config file to manage multiple Git accounts

touch ~/.ssh/config
Host personal
User gitUsername
IdentityFile ~/.ssh/id_rsa

Host work
User gitUsername
IdentityFile ~/.ssh/id_rsa_work
$ git clone personal:username/repository.git
$ git clone work:username/repository.git
$ git remote set-url origin personal:username/repository.git
$ git pull origin branchName // pull latest from  branchName
$ git push origin branchName //push to branchName



Software Engineer []

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store