SSH allows user to set default behaviors when setting up. One problem with SSH is that when a user has multiple sets of SSH keys deployed across different hosts, SSH tends to get confused. This section covers the configurations of SSH Key to host.
The first thing to do is to edit the ~/.ssh/config file that defines all the configurations.
Next, add the default key for any unidentified host. This is the fallback key. Example, say our key is id_KEYLABEL (like id_rsa or id_ed25519):
Host * ForwardAgent yes ForwardX11 no IdentityFile ~/.ssh/id_<KEY LABEL>One example:
Host * ForwardAgent yes ForwardX11 no IdentityFile ~/.ssh/id_ed25519Next, add the key using the following pattern for each hosts:
# Home accountHost <URI> HostName <Anything but usually domain name> PreferredAuthentications publickey IdentityFile ~/.ssh/id_<KEY LABEL>One example:
# Home accountHost home.github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_home# Company accountHost company.github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_companyOnce it's done, save the file and SSH will react accordingly. That's all about configuring SSH to use correct key for correct host.