zencitta / 261854162

Notes
0 stars 0 forks source link

ngrok setup #24

Open zencitta opened 7 years ago

zencitta commented 7 years ago

install golang version after 1.6

//for ubuntu
curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
tar -xvf go1.6.linux-amd64.tar.gz
mv go /usr/local
nano ~/.profile
export PATH=$PATH:/usr/local/go/bin
source ~/.profile

get source code

apt-get install git
git clone https://github.com/inconshreveable/ngrok.git ngrok`

generate ssl cert and key

$ cd ngrok
$ openssl genrsa -out rootCA.key 2048
$ openssl req -x509 -new -nodes -key rootCA.key -subj "/CN=base_url" -days 5000 -out rootCA.pem
$ openssl genrsa -out device.key 2048
$ openssl req -new -key device.key -subj "/CN=base_url" -out device.csr
$ openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 5000

copy keys to folder

cp rootCA.pem assets/client/tls/ngrokroot.crt
cp device.crt assets/server/tls/snakeoil.crt
cp device.key assets/server/tls/snakeoil.key

complie source code

make release-server
make release-client

start server

ngrokd -domain="base_url" -httpAddr=":8088"

edit ngrok.cfg for client

server_addr: "base_url:4443"
trust_host_root_certs: false
tunnels:
    http:
        proto:
            http: 80
        subdomain: test
    https:
        proto:
            https: 443
        subdomain: test2
    ssh:
        remote_port: 5000
        proto:
            tcp: 22

autostart client when powered on

edit /etc/rc.local, add follow commands before exit 0
(sleep 3; /home/pi/proj/ngrok/ngrok -config /home/pi/proj/ngrok/ngrok.cfg start http ssh) &
zencitta commented 7 years ago

run ngrok with screen

  1. scree -S session_name start new session with defined name
  2. run ngrok command
  3. ctrl+A D detach session
  4. screen -r session_name attach session
  5. screen -ls list all seccsions