Automating Site Deployment to

Getting Started:

To begin, you will need the following packages installed:

  • tar
  • pigz
  • scp
  • ssh
  • bash
Automating Site Deployment to

In order to use this script you must first create an ssh key and pass the public key to your server.

ssh-keygen -b 4096

Press enter to select the default options. Do not specifiy a password for your key unless you modify the deploy script to handle this.

To share the newly created public key simply run the following command:


More information can be found on how to make an ssh key at the following link: use-public-key-authentication-with-ssh

Once the server has your public ssh key, create the following script in your public_html directory and then execute the script.

cd ..
cp -r public_html html
tar -cf - html | pigz > html.tar.gz
scp html.tar.gz
ssh 'tar -xvf html.tar.gz; rm -rf public_html; mv html public_html; rm html.tar.gz'
rm -rf html html.tar.gz
printf "\nDeploy has completed successfully\n"
exit 0

Thats it! After the script has exited successfully, your newly updated site should be deployed!