In my local environment (Mac OS X) I have at my home folder the .ssh folder, where there are two keys: github_rsa and id_rsa; in addition, there is a known_hosts file saying some like:
github.com,192.30.252.131 ssh-rsa blahblah
192.30.252.129 ssh-rsa blahlllblahhhh
...
Is there a way (command line preferred) for me to know which key my git command is using when interacting with Github or Bitbucket? If so, how?
Thanks.
The id_rsa.pub
file contains the RSA public key for your user (generally the key used for connecting to GitHub, if you follow their tutorial). If you want to use the github_rsa
key, you can change the key used to connect to GitHub by creating a new host definition in the ~/.ssh/config
file:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_rsa
By the way, the known-hosts
file contains the servers you have connected to and their public keys.
See also this SO question: Setting up ssh keys for GibHub