For context, I am trying to create a deploy script on my local machine (A) to deploy my code to a remote server (B). I don't have root access on B.
Here are the contents of my bash script pertaining to this:
ssh $SSH_ENDPOINT /bin/bash << EOF
cd ~/$PROJECT
git pull
I can ssh in successfully, then cd into the directory. However, git pull fails with:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
On both A and B, I have set up SSH with GitHub and it works fine, I can push and pull without having to enter any passphrase or anything of the sort.
I'm not completely sure why this error is being thrown as both public keys should work.
EDIT: Doing -vv with ssh gives:
debug2: channel 0: rcvd ext data 32
Permission denied (publickey).
debug2: channel 0: written 32 to efd 6
debug2: channel 0: rcvd ext data 126
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Not quite sure how to proceed from here.
sshcommand starts a noninteractive shell, which means that your ordinary configuration files (.bash_profileor.bashrc, e.g.) won't be sourced. That might affect ... something.-vv(add more v's depending on the needed level of detail).-vvtosshand the only thing extra printed is as per my edited post.ssh -vvoutput about which public key is being offered to the remote ssh daemon, like this:debug1: Offering public key: <...>ssh-add ~/.ssh/yourkey) and then usingssh -Ato forward the authentication agent to server B.