0

Preamble

Basically, I followed the recommendations in this other tread.

The situation

I have in my ~/.ssh/ two keys. id_dsa_git (the one I use for github) and id_rsa.

So, when I try to connect to Github, git still use id_rsa instead of id_dsa_git

My configuration

In my ~/.ssh/config I have the following configuration:

Host github
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_dsa_git
    AddKeysToAgent yes
    PubKeyAuthentication yes

And the relevant files have the needed rights:

.rw------- 824 fauve 27 juil. 15:24 /home/fauve/.ssh/config
.r-------- 672 fauve  6 mars   2022 /home/fauve/.ssh/id_dsa_git

The problem

But, git still give me id_rsa:

git clone git@github.com:torvalds/linux.git
Cloning into 'linux'...
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.121.3'
Offending key for IP in /home/fauve/.ssh/known_hosts:57
Matching host key in /home/fauve/.ssh/known_hosts:76
Are you sure you want to continue connecting (yes/no)? yes
Enter passphrase for key '/home/fauve/.ssh/id_rsa':

The question

How to force git to use id_dsa_git instead of id_rsa ?

Kenster
  • 8,620
fauve
  • 245

2 Answers2

1

Change

Host github

to

Host github github.com

0

You don't have any Host or Match section that would match the github.com name that you're connecting to. If you want the Host github section to be applied, you need to specify github as the destination in your SSH command (i.e. git clone git@github:foo/bar in the git command).

grawity
  • 501,077