| 1 | #!/bin/bash -xe |
| 2 | |
| 3 | function print_usage { |
| 4 | echo \ |
| 5 | " |
| 6 | usage: $0 PORT REMOTE_PORT user@proxy |
| 7 | script that sets up a reverse ssh tunnel, and optionally starts a VNC server as well if the START_VNC environment variable is not null |
| 8 | PORT is the port that your techy needs access to. In general, for graphical issues use 5900 and for command-line issues use 22 |
| 9 | REMOTE_PORT is the port that you'll get on the proxy server, any number over 1000 works as long as you and your techy plug in the same number |
| 10 | user@proxy is just your username at the remote proxy machine |
| 11 | " |
| 12 | } |
| 13 | |
| 14 | [ -n $@ ] || print_usage |
| 15 | |
| 16 | PORT_TO_FORWARD=$1 |
| 17 | REMOTE_PORT=$2 |
| 18 | PROXY=$3 |
| 19 | |
| 20 | ssh -T -R $REMOTE_PORT:localhost:$PORT_TO_FORWARD $PROXY |
| 21 | |
| 22 | # quick code that starts up a VNC server for us, if we like |
| 23 | # this won't run if START_VNC is set |
| 24 | [ -n $START_VNC ] || exit |
| 25 | DISPLAY="${DISPLAY:-:0}" |
| 26 | # -forever - x11vnc won't exit after the first disconnect |
| 27 | # -shared - allow multiple clients to share the same screen |
| 28 | # -localhost - only allow connections that are tunneled through localhost |
| 29 | x11vnc -forever -shared -localhost |