Skip to content

Instantly share code, notes, and snippets.

@rlan
Last active February 14, 2019 00:29
Show Gist options
  • Select an option

  • Save rlan/6b2d0d1ebb429175a3b5c68723117cce to your computer and use it in GitHub Desktop.

Select an option

Save rlan/6b2d0d1ebb429175a3b5c68723117cce to your computer and use it in GitHub Desktop.
Port forwarding through a gateway server using SSH tunneling
#!/bin/bash -x
#
# Usage:
# sshtun gpu01
# sshtun gpu02 -t docker run -it --rm -p 48888:8888 -p 46006:6006 tensorflow/tensorflow:1.12.0-py3
#
PORT1=6006
PORT2=8888
FORWARD1=46006
FORWARD2=48888
# Fixme
GATEWAY=username@gateway.address
ssh -L $PORT1:localhost:$FORWARD1 -L $PORT2:localhost:$FORWARD2 $GATEWAY -t \
ssh -L $FORWARD1:localhost:$FORWARD1 -L $FORWARD2:localhost:$FORWARD2 \
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment