Multiple Git Account Setup (Ubuntu version)

ssh-add is a command for adding SSH private keys into the SSH authentication agent for implementing single sign-on with SSH. The agent process is called ssh-agent;

The cool thing about ssh-agent and ssh-add is that they allow the user to use any number of servers, spread across any number of organizations, without having to type in a password whenever moving between servers. This is commonly used by system administrators to move among the machine they administer. It is also widely used in universities and research institutions for accessing computing resources.

More paractical example would be: when anyone shift to new organization and get a new organization email address for the specific organization. He/She might need to create a VCS(version control system) account at github, bitbuckt, gitlab etc. Most Developer already have one personal account on any of the those VCS sites. So to setup this two account on a single machine sometime complex. In this post we will learn how to setup two or more VCS account on a single machine.

The below command will work on Ubuntu and Mac but Windows may not. But In windows, using window subsystem (WSL) will solved below command issue.

Step 1: Create ssh key for different email address

# With Office Email
ssh-keygen -t rsa -b 4096 -C "" -f

# With Personal Email
ssh-keygen -t rsa -b 4096 -C "" -f rezwanul-haque

add this ssh public keys to respective VCS accounts

Step 2: Create a config file on .ssh file

touch config

sudo vim config

Add this

# Personal account - default config
        User git
        IdentityFile ~/.ssh/rezwanul-haque
# Work account - Viva
        User git
        IdentityFile ~/.ssh/

Step 3: Create common ~/.gitconfig file at home directory

sudo vim ~/.gitconfig

Add this to ~/.gitconfig

# Default account-Personal
        name = rezwanul-haque
        email =
# Professional account-Office
[includeIf "gitdir:~/<office_work_space_path>/"]
        path = ~/<office_work_space_path>/.gitconfig-viva

Step 4: Create organization specific gitconfig to organization workspace folder

# Professional account-organization
    name = rezwanul-haque-viva
    email =

Step 5: remove ssh keys and entities from the SSH agent

ssh-add -D

Step 6: Add keys and entities

ssh-add rezwanul-haque

# Check if added or not
ssh-add -l

Step 7: Test with Connection using ssh

ssh -T
ssh -T

Also read this aricle on my personal gist

Step 8: Cloning any project with organization account(required)

# need to add github-hostname
git clone git@<HostName>:Rezwanul-Haque-Viva/<office_project_repo>.git

Example: git clone<office_project_repo>.git

Yml or Yaml for DevOps

As software engineers, we are always learning new tech stacks as we process our careers. Everyone who works on any short of software farm all came across a term called DevOps. As the name suggests, ...

Working with DocuSign, Authorization and Sending Document for Signature

DocuSign is a well known platform where users can send their document for signing via email or your app. I will try to show you how DocuSign authorize an user and how can we send a document to users ...

Worker Pool in Golang

Tags: #advance #topic #golang #goroutine #channels #workerpool #threadpool Often we end up with some work which is so time-consuming that if we’re able to assign, multiple person/worker, to do ...
java web application

Top 9 Practical Benefits Of Using Java Web Application

Java web application frameworks have one of the greatest and largest communities of software engineers in the world. Companies can build a team with the help of this community at ease. There are different communities to help beginners, intermediate as well as expert developers.

Read More