When I visit raspberry pi' ssh server on some places, I must set port forwarding on the home route, and set a dynamic DNS. If the route is not your's, you will helpless.
I think it may have another way, so I try ssh port forwarding ssh -CfNgR remote-port:localhost:local-port user@remote, then visit the remote-port.
The hole is an other way similar ssh port forwarding. On the global server create a holed, and the target host starthole. Last you can visit the holed to replace the real server.
The hole suit the situation: A(private) can connect B(global), C(private) can connect B, but B can't connect C, B can't connect A, and A can't connect C.
The hole support protocol tcptcp6 and unix socket.
Install
go get -v github.com/Lupino/hole/cmd/holed
go get -v github.com/Lupino/hole/cmd/hole
Quick start
# Start on B
holed -addr=tcp://B-IP:B-PORT
# Start on C
hole -addr=tcp://B-IP:B-PORT -src=tcp://localhost:C-PORT
# On A just vist tcp://B-IP:B-PORT to replace visit C server
Example:
# A IP is 192.168.1.101
# B IP is 120.26.120.168
# C IP is 172.17.3.10
# Now on B server
holed -addr=tcp://120.26.120.168:4000
# On C server
hole -addr=tcp://120.26.120.168:4000 -src=tcp://127.0.0.1:22
# On A server
ssh root@120.26.120.168 -p 4000
# Now A can visit C via B server
Connect with tls
go get -v github.com/Lupino/hole/cmd/hole-keys
hole-keys
holed -use-tls
hole -use-tls
$ holed --help
Usage of holed:
-addr string
server address. (default "tcp://127.0.0.1:4000")
-ca string
The ca file. (default "ca.pem")
-key string
The ca key file. (default "ca.key")
-use-tls
use TLS
$ holed -addr tcp://holehub.com:4000 -ca ca.pem -key ca.key -use-tls
2015/08/29 17:09:18 Hole proxy server started on tcp://holehub.com:4000
客户端
我现在是要把本地的 :3000 端口映射出去:
$ hole --help
Usage of hole:
-addr string
Hole server address. (default "tcp://127.0.0.1:4000")
-cert string
The cert file. (default "cert.pem")
-key string
The cert key file. (default "cert.key")
-src string
Source server address. (default "tcp://127.0.0.1:8080")
-use-tls
use TLS
$ hole -addr tcp://holehub.com:4000 -cert cert.pem -key cert.key -use-tls -src tcp://:3000
2015/08/29 17:15:08 Connect Hole server: tcp://holehub.com:4000
2015/08/29 17:15:08 Process: tcp://:3000
Use holehub link to manage your IoT devices or as a lightweight alternative to VPN for targeted access into customer networks.
Download and Installation
holehub is easy to install. Download a single binary with zero run-time dependencies for any major platform. Unzip it and then run it from the command line.
# signup on holehub.com
curl -d username=yourusername -d password=yourpassword -d email=youremail http://holehub.com/api/signup/
# then go to you email inbox active you account
Process the client:
# Login holehub.com
holehub login
# run a app
holehub run --rm -n sshd -lp 22