Created
March 18, 2019 18:42
-
-
Save awestendorf/54a86a10928fc12a315ef6552b14985c to your computer and use it in GitHub Desktop.
Put a local file on to a remote system using an SSH tunnel through a gateway
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 | |
# Fetch a file from a host in a datacenter. Example: | |
# ./put-file.sh my-datacenter my-host ~/local.file ~/my.file | |
# spawn tunnel | |
ssh -n -t -t -L 22000:$2:22 $1 & | |
TUNNEL=$! | |
sleep 5 | |
# need to turn off host checking because localhost:22000 will change as | |
# you connect to different datacenters | |
scp -r -P 22000 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $3 localhost:$4 | |
kill $TUNNEL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment