Permission denied (publickey) outside home directory

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?

2

1 Answer

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.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like