Last active
December 24, 2021 07:36
-
-
Save githubsaturn/b092f0f784263ebf2696c5613e9144e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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