We have a server ( hosting ) and we need to git pull every morning by manually. We have tried to make it easier by a shell script file.
# /bin/bash
# add key
ssh-add /Users/ownner/Documents/keys/key.pem
# Access the server
ssh [email protected] -p18181
# Wait and type the password
# Each to check
echo "Hello, I am in the server now"
# Move to the folder
cd www/folder1/public_html/wp-content/plugins
# Git pull
find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;
It works fine until adding the password. But it is not working after that. The less of code work when I "exit" ssh.
I believe I have missed something. FYI, We actually need to git pull on 6 folders. ( folder1, folder2, folder3, folder4, folder5, folder6 ). So we will use "for each" for the loop.
Can you please give us a tip how the cd, git pull work after login ( access ) the server?
Thank you,
man ssh. ssh foo@bar [command]. So you can append commands to the ssh-line.