I need to use git from a directory located in Desktop. When I use ssh <url> it gives

no such identity: .ssh/id_rsa: No such file or directory
Permission denied (publickey)

However, I can connect to the server if I shh from home directory. How I can update ./ssh to make it accessible from any directory?

  • 1
    What command are you using to connect by ssh? – Arronical May 18 '17 at 14:33
  • I want to run : git push origin master – n.a.s May 18 '17 at 16:53

It seem like you may have made an error when setting up git to use the ssh keys. The error would be using the path .ssh/id_rsa when really you needed ~/.ssh/id_rsa, which will tell the ssh-agent to look in the .ssh directory in your home directory. Currently it will be searching for the .ssh directory in the current directory, which is why it works when you're in the home directory.

Assuming that you set up your ssh keys in a manner similar to the github tutorial, you'll need to remove your faulty configuration from the ssh-agent, and add the key with the correct path.

To remove the incorrect key, while in your home directory:

ssh-add -d .ssh/id_rsa

Add the key with the correct path:

ssh-add ~/.ssh/id_rsa

The key should now be available from any directory.

  • Hi Arronical. Your answer was super helpful for me. I did as you mentioned, I also update the .ssh/config file and set (IdentityFile ~/.ssh/id_rsa). Thank you! – n.a.s May 19 '17 at 20:26
  • Glad it worked. You can accept the answer and upvote it with the check and the upwards arrow on the left hand side if you like. – Arronical May 20 '17 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.