4 ms·
There are a couple solutions to "too many keys". The simplest and best solution is don't use SSH. For Git remotes using HTTPS, use personal access tokens / API
by throwaway984393 5y ago
There are a couple solutions to "too many keys".
The simplest and best solution is don't use SSH. For Git remotes using HTTPS, use personal access tokens / API tokens. For each repository you check out, change the git remote URL to include the username, like git remote add origin https://username@github.com/user/repo.git https://username@github.com/user/repo.git. Then configure Git to use your system's credential keychain and store your token there with the hostname and username. Or use a .netrc file. The correct access token will be selected based on the hostname and username.
If you do use SSH, you can configure a Git repo to use some specific SSH arguments to specify the key file, like git config core.sshCommand "ssh -i ~/.ssh/id_ed25519_clientX". Or you can configure your SSH client to have a custom Host entry for a fake host that specifies the SSH key to use, and use that fake host for your Git ssh remote URL.
- maccolgan 5y agoUsing hostnames like a.github.com and b.github.com and in your ~/.ssh/config and adding Host entries with IdentityFiles pointing to the right private keys is the cleaner solution imo.
- koolba 5y agoHow is this better than using IdentiesOnly and explicitly listing the one and only key that should be used for a given destination?