4

I am having some issues with using git (github) on a remotely accessed machine. I am logging in from home into my work computer via ssh e.g.

me@home$ ssh me@work 

after which I try to do a pull or push request to github on my work computer via home e.g.

me@workViaHome$ git pull origin branch 

after which I receive the error:

Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

I have tried loading the ssh key from my work computer using:

me@workViaHome$ eval "$(ssh-agent -s)" me@workViaHome$ ssh-add ~/.ssh/id_rsa 

but still no luck. When I am physically at my work computer I can issue requests to github without any issues; so it seems the issue with with the status of my ssh-keys due to my ssh session.

Thanks for any help!

2
  • Verify that the private key you've added on workViaHome is actually the right one for the public key you've added on github. Also verify that the access permissions for the ~/.ssh directory are correct. Finally, try to ssh to github using the same user/port as git, and add the verbose flag to get more info. Commented Jul 17, 2017 at 6:54
  • So I isolated the issue to ssh-add not triggering git to use the ~/.ssh/id_rsa key, it was still trying to use the default key. I cheated for now in that I added the default key to github and it works. I used ssh -vT [email protected] to figure it out. I'm still not sure why ssh kept falling back to the default key Commented Jul 17, 2017 at 7:09

1 Answer 1

2

SSH is using the default keys if it is not specified otherwise in configuration or if the ssh-agent is not providing any other key.

If you are using a key in nonstandard location, that you have added in your gnome-keyring, you could notice this behavior, because gnome-keying starts only for the graphical sessions, but not for ssh sessions.

Certainly, you can resolve this by properly configuring this key in ~/.ssh/config on the work computer. Just add

Host github.com IdentityFile ~/.ssh/path_to_key IdentitiesOnly yes 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.