I'm trying to ssh from server 1 to server 2 and do a git pull
from server 1 to server 2.
So on server 1, I run the following command:
ssh root@server2 'cd /root/.example; git pull origin master'
but that gives me this error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
It's able to ssh because when I do an ls (ssh root@server2 'cd /root/.example; ls
) I see the contents of the /root/.example
directory. It's just not able to do a git pull origin master
because it uses the wrong key.
What can I do differently?
I'm using Centos 6.
ssh -A
may be required).