Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Git ignores ~/.ssh/id_rsa, wants ~/.ssh/id_dsa or ~/.ssh/id_ecdsa?

Tags:

git

ssh

This is the error I'm receiving:

no such identity: /home/eduan/.ssh/id_dsa: No such file or directory
no such identity: /home/eduan/.ssh/id_ecdsa: No such file or directory
Permission denied (publickey).

That's what happens when I try to push, or in this case when I do ssh -T [email protected].

I have correctly generated the id_rsa and id_rsa.pub files.

How may I go about solving this? I'm using Arch Linux with E17 BTW.

EDIT:
@kortix would the following work for this?:

Host github.com
    IdentityFile ~/.ssh/id_rsa

It doesn't seem to work for me yet... I get the following when I push with Git:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I made sure the repo exists, and I also updated the remote URL with git remote set-url origin [email protected]:Greduan/dotfiles.git.

I also added the SSH key to the list of accepted SSH keys in GitHub. What else should I do?

like image 424
greduan Avatar asked Apr 17 '13 16:04

greduan


People also ask

How does Git know which SSH key to use?

Git does not know, or care. It just runs ssh. Specifies that ssh(1) should only use the authentication identity files configured in the ssh_config files, even if ssh-agent(1) or a PKCS11Provider offers more identities. The argument to this keyword must be “yes” or “no”.

How do I get Git to stop asking for passphrase?

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

Where does Git store ssh keys?

SSH keys are stored in the ~/. ssh folder. You can have more than one key in there, because SSH keys are used for things other than Git. The .


1 Answers

The SSH client tells you about id_dsa (note the "d" — it stands for DSA) while you've generated id_rsa (note the "r" which stands for RSA).

You should either generate a DSA key or tell SSH which "identity" (the private key) to use. This could be done using the IdentityFile directive under a custom Host entry in your ~/.ssh/config file for the github remote (see the ssh_config(5) manual page).

Update (2013-04-29, to make it clearer for the next reader). The essense of the problem was that the OP has wrong owner (root) on his ~/.ssh/id_rsa key, so the OpenSSH client first tried to read that key, failed, and then went on trying to read ~/.ssh/id_dsa and ~/.ssh/id_ecdsa, in turn, which also failed — this time because they simply did not exist. Having no more keys to use for pubkey authentication and no available authentication mechanisms, the SSH client failed. Those "No such identity ..." messages were actually warnings.

like image 160
kostix Avatar answered Nov 03 '22 00:11

kostix