Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git is looking for a wrong SSH key

Tags:

git

ssh

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?

like image 633
keddad Avatar asked Jun 28 '19 08:06

keddad


2 Answers

try this:

ssh-add ~/.ssh/correct_key
like image 108
Watson Avatar answered Sep 21 '22 10:09

Watson


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
like image 37
keddad Avatar answered Sep 19 '22 10:09

keddad