0

When I try to ssh -C user@my_server 'cd /home/me/my_repo' it works. When I try to ssh user@my_server, then cd /home/me/my_repo' and then git pull it works.

But when I try to ssh -C user@my_server 'cd /home/me/my_repo' && git pull it fails with Permission denied (publickey).

My question really is : Why does it even work locally? When I do ssh -C user@my_server 'cd /home/me/my_repo && git pull'does git care about what ssh key I used to connect to my_server, not just the ssh key used to connect to my_repo's remote?

yPhil
  • 103
  • 4

1 Answers1

0

SSH by default will use the keys inside your .ssh directory. This is usually in ~/.ssh/.

It seems you wrote the following command which may be a typo:

ssh -C user@my_server 'cd /home/me/my_repo' && git pull

The above command will run ssh, and after a successful completion (exit status 0), run git pull. I am just saying this as it may be related to your issue and hopefully help without being too pedantic.

To answer your question, git will use by default the keys in your .ssh folder on the machine where the command is run.

Therefore is should try to use the keys in the home of user@my_server.

Git does not know about the keys on servers outside of where it resides.

Nathan McCoy
  • 200
  • 2
  • 11