Skip to content

Instantly share code, notes, and snippets.

@jam13
Created August 20, 2018 12:03
Show Gist options
  • Select an option

  • Save jam13/8ba092c9b00ebaa822e202b1e6691a34 to your computer and use it in GitHub Desktop.

Select an option

Save jam13/8ba092c9b00ebaa822e202b1e6691a34 to your computer and use it in GitHub Desktop.
#!/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