I want to create a .command-script on Mac, to execute a series of commands on a remote server using SSH. My script looks something like this:
ssh user@domain.com
cd /var/www/website/
git pull
However, I need to enter my password after the first command (to actually gain access to the remote server). The rest of the script does not get executed after entering my password.
How can I tell the terminal to execute the following commands after I entered my password?
NB: I don't want to put my password in the .command-file.
Best Answer
In this solution we need to tell ssh to create a pseudo terminal with
-tt
then use a heredoc to send the commands to the remote location.