keddad
keddad

Reputation: 1816

Git is looking for a wrong SSH key

I decided to try using SSH to work with my GitHub repos. I modified remote url in git/.config, so now it uses SSH:

[remote "origin"]
        url = [email protected]:keddad/passpoint_server.git
        fetch = +refs/heads/*:refs/remotes/origin/*

But when I ran git fetch, for example, git is looking for a wrong key:

(venv) keddad@keddad-pc:~/PycharmProjects/passpoint_server/.git$ git fetch
no such identity: /home/keddad/.ssh/github_rsa: No such file or directory
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

In the same time, the real key which is added to GitHub is in a file ~/.ssh/id_rsa How do I make git use the id_rsa key?

Upvotes: 12

Views: 13203

Answers (2)

Watson
Watson

Reputation: 3350

try this:

ssh-add ~/.ssh/correct_key

Upvotes: 12

keddad
keddad

Reputation: 1816

Looks like my ~/.ssh/config was poorly configured:

Host github.com
  IdentityFile ~/.ssh/github_rsa
  IdentitiesOnly yes

I needed to change the IdentityFile to a real file, in my case, id_rsa

Host github.com
      IdentityFile ~/.ssh/id_rsa
      IdentitiesOnly yes

Upvotes: 10

Related Questions