When trying to add a SSH key in GitHub, an error “Key is already in use” is thrown even though you signed into GitHub using a different user account.
The error occurs when the same SSH key has been added to a different account. This typically happens when you already have an existing personal GitHub account and you are trying to use the same SSH key in a work-related GitHub Enterprise account.
The fix is to use a new SSH key. When generating the SSH key using ssh-keygen, remember NOT to override the existing ~/.ssh/id_rsa. Rather, use a different file path, such as ~/.ssh/id_rsa_github_enterprise.
To ensure seamless integration when doing a git clone, add the following configuration in ~/.ssh/config.
The first block ensures it doesn’t break the existing GitHub connectivity using the default SSH key.
The second block allows a different SSH key to be used when connecting to GitHub. In order to leverage this configuration, the host name needs to be tweaked when doing a git clone.