I am trying to write a script that ssh into a remote location and then performs a git pull
as follows
ssh url@location << EOF
--other commands--
git pull
--other commands--
EOF
However whenever I run the script it fails the username/password prompt, which it never shows on the terminal. I would actually in this case prefer having to enter my credentials rather than making adjustments to the remote machine, does anyone know how to get the prompts to appear?
CodePudding user response:
You don't need here-doc, you can just write the command as ssh
argument:
ssh url@location git pull
This doesn't allow git
to ask for password because this is command line-only call, and git
requires a terminal to ask for password. So you have to make ssh
to allocate a pseudo-terminal:
ssh -t url@location git pull
If you have more than one command to run — pass them all in quotes:
ssh url@location "cd /path/to/repo && git pull && echo ok"
ssh -t url@location "cd /path/to/repo && git pull && echo ok"
CodePudding user response:
You need to configure your git user on the remote machine with a personal access token, in order to not get the username/password prompt.