Last active
June 12, 2017 08:56
-
-
Save thisismydesign/35e5d6146c91f7a3757f3cc77be7a090 to your computer and use it in GitHub Desktop.
SSH commands to create tunnels
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
$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