T
T
triggerfinger2017-11-28 00:26:44
git
triggerfinger, 2017-11-28 00:26:44

Why doesn't git clone work on a remote server if I run the command through a bash script?

The task is to execute a small script:

ssh [email protected] << 'ENDSSH'
cd /home/me/myapp
pm2 stop myapp
git pull origin master
npm install
npm run build
pm2 start myapp
ENDSSH

Problem: at the stage git pull origin masterI get an error that there are no access rights.
Cloning into 'issue'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

If I execute this command myself by logging into the server via SSH - everything works! So why doesn't it work when I run it through a script? What key is he trying to use? (on the local machine and VPSke different keys for Github, but the account is the same)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor, 2017-11-28
@v_decadence

The server key must be used, not the local machine key.
Maybe different users are used in your script and at manual entry and, accordingly, different keys are taken?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question