Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show SSH key file in Git Bash

Tags:

git

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]

like image 873
Kai Schneider Avatar asked Sep 17 '13 09:09

Kai Schneider


People also ask

How do I find my SSH key file?

Open a terminal and use the ssh-keygen command with the -C flag to create a new SSH key pair. Replace the following: KEY_FILENAME : the name for your SSH key file. For example, a filename of my-ssh-key generates a private key file named my-ssh-key and a public key file named my-ssh-key.

Where are Git ssh keys stored?

The default location is: %HOMEDRIVE%%HOMEPATH%\. ssh\id_rsa.


1 Answers

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 [email protected] 

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.

like image 53
Jan Krüger Avatar answered Oct 08 '22 22:10

Jan Krüger