Skip to content

Instantly share code, notes, and snippets.

@thisismydesign
Last active June 12, 2017 08:56
Show Gist options
  • Save thisismydesign/35e5d6146c91f7a3757f3cc77be7a090 to your computer and use it in GitHub Desktop.
Save thisismydesign/35e5d6146c91f7a3757f3cc77be7a090 to your computer and use it in GitHub Desktop.
SSH commands to create tunnels
$TARGET_PORT=
$TARGET_IP=
$TARGET_USER=
# SSH tunnel to target machine
ssh -f -N -L $TARGET_PORT:localhost:22 $TARGET_USER@$TARGET_IP
# SSH tunnel from target machine (reverse tunnel)
ssh -f -N -R $TARGET_PORT:localhost:22 $TARGET_USER@$TARGET_IP
# SSH tunnel to target machine with machine in the middle
$MIDDLE_IP=
ssh -f -N -L $TARGET_PORT:$MIDDLE_IP:22 $TARGET_USER@$TARGET_IP
# Check if tunnel exists
$SSH_CMD=
pgrep -f -x "$SSH_CMD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment