Skip to content

Instantly share code, notes, and snippets.

@NapoleonWils0n
Created November 11, 2012 15:39
Show Gist options
  • Save NapoleonWils0n/4055254 to your computer and use it in GitHub Desktop.
Save NapoleonWils0n/4055254 to your computer and use it in GitHub Desktop.
ssh: ssh relay server
#!/bin/sh
#-----------------------------------------------------------#
# ssh relay server #
#-----------------------------------------------------------#
# use a ssh server a middle man
# to connect 2 computers behind firewalls
#-----------------------------------------------------------#
# bash shell down the tunnel #
#-----------------------------------------------------------#
# machine 1
ssh -N -R 8080:localhost:22 sshserver
# machine 2
# forward local port 8080 to remote port 8080
ssh -N -L 8080:localhost:8080 sshserver
# connect to localhost port 8080 and down the tunnel
ssh -p 8080 localhost
#-----------------------------------------------------------#
# vnc down the tunnel #
#-----------------------------------------------------------#
# machine 1
ssh -N -R 8080:localhost:5900 sshserver
# machine 2
# forward local port 8080 to remote port 8080
ssh -N -L 8080:localhost:8080 sshserver
# connect to localhost port 8080 and down the tunnel
open vnc://127.0.0.1:8080
#-----------------------------------------------------------#
# web server down the tunnel #
#-----------------------------------------------------------#
# web server - forward port 80
ssh -N -R 8080:localhost:80 sshserver
# forward local port 8080 to remote port 8080
ssh -N -L 8080:localhost:8080 sshserver
# connect to localhost port 8080 and down the tunnel
http://localhost:8080/~username/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment