Created
August 20, 2018 12:03
-
-
Save jam13/8ba092c9b00ebaa822e202b1e6691a34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| BASTION_IP=1.2.3.4 | |
| HOST_IP=10.0.2.235 | |
| SSH_KEY=~/.ssh/id_rsa | |
| REMOTE_PORT=9990 | |
| LOCAL_PORT=9990 | |
| SSH_PROXY_PORT=2222 | |
| function ctrl_c() { | |
| kill $TUNNEL_PID | |
| } | |
| trap ctrl_c INT | |
| ssh -L $SSH_PROXY_PORT:$HOST_IP:22 -N -i $SSH_KEY ec2-user@BASTION_IP & | |
| TUNNEL_PID=$! | |
| sleep 3 | |
| ssh -L $LOCAL_PORT:localhost:$REMOTE_PORT -N -p $SSH_PROXY_PORT -i $SSH_KEY ec2-user@localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment