There will be instances where you have repositories in different git hosting services such as GitHub and GitLab.
This means that you will have 2 different SSH keys on your system but you will need to specify which SSH key to use for each host.
But how do you tell git which SSH key to use for each host?
You need to create a
config file in
/.ssh file and specify which key to use for each host.
/.ssh directory, create a new file called config (
In the config file add your hosts and key file names in this format to tell git which key to use for each host:
In the example above, it specifies that when connecting to a GitHub.com host, use the SSH file
This will allow you to have multiple SSH keys for multiple git hosts.