Skip to content

Instantly share code, notes, and snippets.

@githubsaturn
Last active December 24, 2021 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save githubsaturn/b092f0f784263ebf2696c5613e9144e5 to your computer and use it in GitHub Desktop.
Save githubsaturn/b092f0f784263ebf2696c5613e9144e5 to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir ~/.ssh
# Originally: cat private.key | openssl base64 | tr -d '\n'
echo $PRIVATE_KEY_BASE_64 | openssl base64 -A -d >~/.ssh/private.key
chmod 700 ~/.ssh/private.key
ssh-keyscan -p $REMOTE_SSH_PORT -H $REMOTE_SSH_ADDRESS >>~/.ssh/known_hosts
# Just a simple check to make sure we can SSH to remote
ssh -i ~/.ssh/private.key $REMOTE_SSH_USER@$REMOTE_SSH_ADDRESS -p $REMOTE_SSH_PORT 'date' || echo 'failed'
while true; do
rsync -aPh -e "ssh -i ~/.ssh/private.key -p $REMOTE_SSH_PORT" $REMOTE_SSH_USER@$REMOTE_SSH_ADDRESS:$REMOTE_SOURCE_DIRECTORY /target-dir/ || echo 'failed'
sleep $RSYNC_SLEEP_GAP
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment