-1

Hi i'm having trouble pulling in a remote endpoint.

command to connect from remote google compute engine:

ssh -i /path/.ssh/google_compute_engine NAME@REMOTEIP "cd /home/repo/; git pull origin dev"

Connection via ssh to remote endpoint is working. When i do manually my git pull is working but when i try to pass commands line as arguments it fail :

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Also if i try to add my ssh:

ssh -i /path/.ssh/google_compute_engine NAME@IP "cd /home/repo; ssh-add ~/.ssh/rsa_pub"

it fail:

Could not open a connection to your authentication agent.

ssh -i /path/.ssh/google_compute_engine NAME@IP "ls /home; cd /home/repo; eval ssh-agent;"

return :

SSH_AGENT_PID=311; export SSH_AGENT_PID;
echo Agent pid 311;

I have to use it like this to make a script for production.

I don't find a way to do it, and also avoid entering passphrase so it will automatically pull as i launch of the command below. Can i somehow pass my the rsa_pub as parameter ?

Ernesto U
  • 786
  • 3
  • 14
Yepe
  • 45
  • 1
  • 1
  • 8
  • Might changing the permissions in the .git directory like in this example: https://stackoverflow.com/a/56098268/7099374 do the trick? – Amuoeba Oct 23 '19 at 15:09
  • Did not but thanks for the help ```drwxrwxrw- 8 user user 4096 Oct 23 16:42 .git``` Permission denied (publickey) still – Yepe Oct 23 '19 at 15:43
  • start with the remote command `pwd; whoami`. This will tell you the user context setup by SSH. Then adjust as necessary. Linux has the command `runuser` so that you can specify the user environment for commands. – John Hanley Oct 23 '19 at 17:51

1 Answers1

0

Servers from some providers like AWS will not log you in as root but rather as a user with limited permissions (i.e. ubuntu@ip) try adding sudo before git pull on the server.

frogic
  • 1
  • Thanks for the reply it give me ```Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.``` – Yepe Oct 23 '19 at 15:39