Setting up SSL for multiple git accounts

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
- Login to all git accounts.
- Go to settings.
- Click “SSH and CPG keys”.
- Click on “New SSH key”.
- Enter the preferred title and paste the key.
- Click “Add SSH key”.
- 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.