Last active
June 10, 2020 05:33
-
-
Save sytranvn/24954a35e42d370d3d23d19355036b65 to your computer and use it in GitHub Desktop.
Sync home data
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
#!/usr/bin/env sh | |
# USAGE: transfer.sh [--ignore-existing] [user@]host[:port] <source> <destination> | |
ie="" | |
if [ "$1" = "--ignore-existing" ]; then | |
ie="$1" | |
shift | |
fi | |
if [ -z "$1" ]; then | |
echo "USAGE:\n\t $0 [--ignore-existing] [user@]host[:port] <source> <destination>" | |
exit 1 | |
fi | |
echo 'Install inital packages' | |
sudo apt install -y openssh-client curl rsync | |
echo 'Generate ssh key' | |
cat /dev/zero | ssh-keygen -q -N "" | |
echo 'Sign in remote host' | |
ssh-copy-id -i $HOME/.ssh/id_rsa.pub -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" $1 | |
echo 'Transfer files' | |
rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" -azvpPhl "$ie" "$1:$2" $3 | |
echo 'Finished' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment