Skip to content

Instantly share code, notes, and snippets.

@schliflo
Created November 19, 2018 13:08
Show Gist options
  • Save schliflo/fdcb858ff381e1aee7f96e68ac0ec9f7 to your computer and use it in GitHub Desktop.
Save schliflo/fdcb858ff381e1aee7f96e68ac0ec9f7 to your computer and use it in GitHub Desktop.
rsync deploy via ipsec VPN
# PROJECT SPECIFIC
export DEPLOY_SERVER="SERVER_IP"
export DEPLOY_USER="SSH_USER"
export DEPLOY_PASS="SSH_PASS"
export DEPLOY_DIR="DEPOY_PATH"
export DEPLOY_PORT="22"
export DEPLOY_VPN_USR="VPN_USR"
export DEPLOY_VPN_PASS="VPN_PASS"
export DEPLOY_VPN_URL="VPN_URL"
# GENERAL
export RSYNC="rsync -rtqx --links --safe-links --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r --delete"
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# INSTALL ADDITIONAL TOOLS
sudo apt install -y openconnect sshpass
# CONNECT TO VPN
printf "$DEPLOY_VPN_USR\n$DEPLOY_VPN_PASS\n" | sudo openconnect -b $DEPLOY_VPN_URL
# DEPLOY
sshpass -p $DEPLOY_PASS $RSYNC -e "ssh -p $DEPLOY_PORT" --filter="merge .deploy-filter" . $DEPLOY_USER@$DEPLOY_SERVER:$DEPLOY_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment