Created
March 18, 2019 18:38
-
-
Save awestendorf/392812ee9f2694148331606a3466570c to your computer and use it in GitHub Desktop.
Get a file off 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: | |
# ./get-file.sh my-datacenter my-host ~/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 localhost:$3 ./ | |
kill $TUNNEL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment