Reputation:
I have multiple SSH keys on a single device.
// example
id_rsa_github_office.pub , id_rsa_github_personal.pub
How can I manage multiple SSH keys without conflict on a single device?
Upvotes: 3
Views: 1290
Reputation: 1130
Create config file inside the .ssh directory with name config.
Then inside the config file write down these configurations. Change the your-file-name to your SSH key file-name and change the your-host-name to your preferred host-name
Host <your-host-name>
HostName github.com
User git
IdentityFile ~/.ssh/<your-file-name>
The config file should be looking something like this after the edit.
Then we will clone the same old way using a modified URL
$ git clone git@github-personal:GhostWolfRider/Angular-Admin-Dashboard.git
Check out this medium article to know more >>
Generate & Manage Multiple SSH Keys on a Single Device
Let me know if you still have any questions.
Upvotes: 0
Reputation: 142094
When you have multiple identity files, create a SSH config file mechanisms to create aliases for your various identities.
You can construct a SSH config file using many parameters and different approaches.
The format for the alias entries use in this example is:
Host alias HostName bitbucket.org IdentityFile ~/.ssh/identity
To create a config file for two identities (workid and personalid), you would do the following:
Open a terminal window.
Edit the ~/.ssh/config file.
If you don't have a config file, create one.
Add an alias for each identity combination for example:
Host workid
HostName bitbucket.org
IdentityFile ~/.ssh/workid
Host personalid
HostName bitbucket.org
IdentityFile ~/.ssh/personalid
Don't forget to load the keys to your github account.
SSH keys
Add ssh key
And you all set to go :-)
Upvotes: 4