Show SSH key file in Git Bash

Git

Git Problem Overview


How can I see which SSH key file is used in Git Bash?

I tried "git config --get-all", but I get the error message

> error: wrong number of arguments; usage: git config [options]

Git Solutions


Solution 1 - Git

Which SSH key is used isn't determined by Git, but by the SSH client itself. Either the appropriate key is configured in ~/.ssh/config, or ssh just tries all keys it can find when connecting to the host. You can see which key ultimately succeeded by connecting to the host with the standard SSH client. For example, when using GitHub:

ssh -v git@github.com

This will give you something a bit like this:

[...]
debug1: Offering RSA public key: /home/me/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /home/me/.ssh/id_rsa2
debug1: Server accepts key: pkalg ssh-rsa blen ****
[...]

This tells you that the key .../id_rsa2 was the one accepted by the server.

Solution 2 - Git

Another solution, in the latest Git Bash, you can type:

$ git-gui

Then a GUI application is executing, and in the GUI, you can just click HelpShow SSH Key to show your SSH key.

Solution 3 - Git

This command worked for me:

cat ~/.ssh/id_rsa.pub

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKai SchneiderView Question on Stackoverflow
Solution 1 - GitJan KrügerView Answer on Stackoverflow
Solution 2 - GitMewXView Answer on Stackoverflow
Solution 3 - GitrafiView Answer on Stackoverflow