Setting up SSL for multiple git accounts

Amesh Jayaweera
2 min readJul 20, 2020

--

Photo by Yancy Min on Unsplash

This article is a quick guide for setup SSL to your multiple git accounts. Let’s start now.

Step 1 — Generate SSH Keys

Check whether there are any existing SSH keys available to reuse. You can use ls -al~/.ssh command to check it. If there are no keys, you can use ssh-keygen -t rsa -C “your_git_account_email” to generate new SSH keys for each git account. After generating it will be asked the location to save the key file. Press enter to leave the default location.

Step 2 — Adding SSH keys to git accounts

  1. Login to all git accounts.
  2. Go to settings.
  3. Click “SSH and CPG keys”.
  4. Click on “New SSH key”.
  5. Enter the preferred title and paste the key.
  6. Click “Add SSH key”.
  7. Repeat steps to for your all git accounts.

Step 3 — Register new SSH key in ssh-agent

You can use eval "$(ssh-agent -s)" command to start ssh-agent. Then add keys to ssh agent by ssh-add ~/.ssh/saved_ssh_key_file_name commad.

Step 4 — Create SSH config file

Ok. This the last step you have to follow.

First, create an SSH config file by following commands.

   cd  ~/.ssh
touch config
subl -a config

Then, in the config file, you can set up your all accounts as follows.

#  account 1Host  github..comHostName  github..comUser  gitIndeittyFile~/.ssh/saved_ssh_key_filename# account 2Host gitlab.comHostName gitlab.comUser gitIndeittyFile~/.ssh/saved_ssh_key_filename

Finally, you can go ahead with the corresponding repositories using the SSH keys.

Thanks for reading.

--

--

Amesh Jayaweera

I’m passionate to explore the knowledge and improve my skills level best in Science & Technology including Programming, and Artificial Intelligence.