Multiple git accounts with multiple ssh keys in the same device

I have multiple git accounts one is for my personal use and one is for company use. Both account sources need to be activated from the same device.
No problem, here we see, How to maintain multiple git accounts with multiple ssh keys in the same device.
Let’s go…
multiple git accounts with multiple ssh keys
Suppose that you have 2 bitbucket accounts witch usernames are username1 and username2.
Step 1:
Open the terminal and create 2 ssh file2 for both usernames:
ssh-keygen -f ~/.ssh/username1-Bitbucket ssh-keygen -f ~/.ssh/username2-Bitbucket
Step 2:
Create or edit the ~/.ssh/config file
Create:
touch ~/.ssh/config open ~/.ssh/config
Edit:
open ~/.ssh/config
The ~/.ssh/config file should look like this:
Host bitbucket.org-username1 HostName bitbucket.org User username1 IdentityFile ~/.ssh/username1-Bitbucket IdentitiesOnly yes Host bitbucket.org-username2 HostName bitbucket.org User username2 IdentityFile ~/.ssh/username2-Bitbucket IdentitiesOnly yes
Step 3 or Final Step:
Change your remote git URL to have your username before ‘@bitbucket.org’
git remote add origin [email protected]:company/app.git
or
git remote set-url origin [email protected]:company/app.git
If you have not yet cloned your repository:
git clone [email protected]:company/app.git
Now enjoy….