1. Linux

  • Note: When a SSH port is already used by another ngrok service you get the following error when executing:

    /usr/local/bin/ngrok -config=/etc/ngrok start client ssh
    Server failed to allocate tunnel: [ctl:3252b5a9] [c7994ac0114274bb0dbb0be287b55506]
    Error binding TCP listener: listen tcp 0.0.0.0:60501: bind: address already in use
  • See https://ngrok.com/usage.

  • See https://ngrok.com/user/signup.

1.1. Client Installation

  • Install Apache.

  • Install PHP.

  • Log in as <user>.

  • Start Terminal.

  • Type cd ~/Downloads and press Enter.

  • Download the latest linux version from https://ngrok.com.

cd /tmp* and press Enter.
unzip ~/Downloads/ngrok.zip
sudo mv ngrok /usr/local/bin
which ngrok
ngrok version
ngrok help

1.2. Client Configuration

  • Log in as <user>.

  • Start Terminal.

  • Contents of the /etc/ngrok file.

auth_token: suA3PtGLqKcweMKmYuuB

tunnels:
  client:
    subdomain: "<hostname>.smru"
    auth: "smru:********"
    proto:
      http: 80
  ssh:
    remote_port: 60301
    proto:
      tcp: 22
  • Use the level l2 password for the auth parameter.

  • Type sudo chmod 600 /etc/ngrok and press Enter.

  • Type vdir /etc/ngrok and press Enter.

  • Type sudo a2enmod ssl and press Enter.

  • Type sudo service apache2 restart and press Enter.

  • Type sudo ngrok -config=/etc/ngrok -log=none start client ssh and press Enter.

  • Close Terminal.

  • Start Browser.

  • Connect to http://<hostname>.smru.ngrok.com.

User Name:              smru
Password:               ********

1.3. Service Configuration

?   Operating system    Apache2         MySQL           Postgresql
?   ----------------    ----------      -----           -------------
?   Debian 6.0.8        S20apache2      S21mysql        S21postgresql
?   Debian 7.2          S17apache2      S18mysql        S18postgresql
?   Debian 7.6          S17apache2      S18openvpn      S19postgresql
?   Ubuntu 12.04        S91apache2      upstart         S19postgresql
?   Ubuntu 12.10        S91apache2      upstart         S19postgresql
?   Ubuntu 13.04        S91apache2      upstart         S19postgresql
?   Ubuntu 13.10        S91apache2      upstart?        S19postgresql
  • Log in as <user>.

  • Start Terminal.

  • Type sudo cp -a /etc/init.d/skeleton /etc/init.d/ngrok and press Enter.

  • Type sudo chmod a+x /etc/init.d/ngrok and press Enter.

  • Make the following changes (see below) to the /etc/init.d/ngrok file.

  • Type diff /etc/init.d/skeleton /etc/init.d/ngrok and press Enter.

3,5c3,5
< # Provides:          skeleton
< # Required-Start:    $remote_fs $syslog
< # Required-Stop:     $remote_fs $syslog
---
> # Provides:          ngrok
> # Required-Start:    $all
> # Required-Stop:     $all
8,10c8
< # Short-Description: Example initscript
< # Description:       This file should be used to construct scripts to be
< #                    placed in /etc/init.d.
---
> # Short-Description: Start stop ngrok
13,17d10
< # Author: Foo Bar <foobar@baz.org>
< #
< # Please remove the "Author" lines above and replace them
< # with your own name if you copy and modify this script.
<
22,25c15,18
< DESC="Description of the service"
< NAME=daemonexecutablename
< DAEMON=/usr/sbin/$NAME
< DAEMON_ARGS="--options args"
---
> DESC="ngrok service"
> NAME=ngrok
> DAEMON=/usr/local/bin/$NAME
> DAEMON_ARGS="-config=/etc/ngrok -log=none start client ssh"
52c45,46
<       start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
---
>       sleep 5 # Wait for network to be up.
>       start-stop-daemon --background --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
54c48
<       start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
---
>       start-stop-daemon --background --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  • Type sudo runlevel and press Enter.

  • Type vdir /etc/rc2.d and press Enter.

  • Type sudo update-rc.d ngrok defaults and press Enter.

  • Type vdir /etc/rc2.d and press Enter.

S22ngrok -> ../init.d/ngrok
  • Close Terminal.

  • Restart the computer.

  • Log in as <user>.

  • Start Terminal.

  • Type ps ax | grep -i ngrok and press Enter.

  • Type sudo service ngrok status and press Enter.

  • Optional: Type sudo service ngrok stop and press Enter.

  • Optional: Type sudo service ngrok start and press Enter.

  • Optional: Type sudo service ngrok restart and press Enter.

  • Close Terminal.

1.4. Forwarding of HTTP services

  • Log in as <user>.

  • Start Terminal.

  • Type ngrok 80 and press Enter.

  • Type ngrok -authtoken KSGyRwtDCw9daFbGPmtl 80 and press Enter.

  • Type ngrok -subdomain=smru 80 and press Enter.

  • Type ngrok -httpauth="helmet:12345" 80 and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              http://5423d2d7.ngrok.com -> 127.0.0.1:80
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms

1.5. Forwarding of SSH service

  • Log in as <user>.

  • Start Terminal.

  • Type ngrok -proto=tcp 22 and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              tcp://ngrok.com:58071 -> 127.0.0.1:22
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms
  • Start PuTTY.

Host Name:              ngrok.com
Port:                   58071
  • Close PuTTY.

  • Close Terminal.

1.6. Debugging ngrok client

tunnel.LocalAddr:       127.0.0.1:22
startPxy.Url:           tcp://ngrok.com:60501
c.authToken:            KSG....
c.configPath:           /etc/ngrok
c.id:                   482e...
c.proxyUrl:
c.serverAddr:           96.126.125.171:443
c.serverVersion:        1.5
  • Type sudo ngrok -config=/etc/ngrok start client ssh and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              http://<hostnmae>.smru.ngrok.com -> 127.0.0.1:80
Forwarding              tcp://ngrok.com:60301 -> 127.0.0.1:22
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms
  • Press Ctrl+C to exit ngrok.

2. macOS

3. Windows

SMRUWS-IT10 C:\Tmp\ngrok# ngrok.exe authtoken mpG4FkUKwQiYETtRL7tW_6Fr3vQkUMZxtiupMTRsxh
Authtoken saved to configuration file: C:\Users\Administrator/.ngrok2/ngrok.yml
ngrok.exe tcp 22

3.1. Client Installation

  • Logon as Administrator.

  • Download the latest Windows version from https://ngrok.com.

  • Start Windows Explorer.

  • Create the C:\Program Files (x86)\ngrok folder.

  • Extract the ngrok.zip archive to the C:\Program Files (x86)\ngrok folder.

  • Close Windows Explorer.

  • Start Command Prompt.

  • Type cd "C:\Program Files (x86)\ngrok" and press Enter.

  • Type where ngrok and press Enter.

  • Type ngrok version and press Enter.

  • Type ngrok help and press Enter.

  • Close Command Prompt.

3.2. Client Configuration

server_addr: "xxxxx.net:443"
trust_host_root_certs: false
http_proxy: "http://proxy:8080"
  • Logon as Administrator.

  • Contents of the C:\Program Files (x86)\ngrok\ngrok.cfg file.

auth_token: suA3PtGLqKcweMKmYuuB

tunnels:
  client:
    subdomain: "<hostname>.smru"
    auth: "smru:********"
    proto:
      http: 80
  ssh:
    remote_port: 60303
    proto:
      tcp: 22
  • Use the level l2 password for the auth parameter.

"C:\Program Files (x86)\ngrok\ngrok.exe" -config="C:\Program Files (x86)\ngrok\ngrok.cfg" start client ssh

https://smruws-it10.smru.ngrok.com
https://smruws-it10.smru.ngrok.com      60303
ngrok.com 60303

3.3. Service Installation

@ECHO OFF
"C:\Program Files (x86)\ngrok\ngrok.exe" -config="C:\Program Files (x86)\ngrok\ngrok.cfg"
  • Select Start | Programs | Accessories | Command Prompt.

  • Optional: Type sc.exe stop Ngrok and press Enter.

  • Optional: Type instsrv.exe Ngrok remove and press Enter.

  • Type instsrv.exe Ngrok "C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe" and press Enter.

  • Type regedit and press Enter.

  • Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok.

  • Select Edit | New | Key and type Parameters and press Enter.

  • Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok | Parameters.

  • Select Edit | New | String Value and type Application and press Enter.

  • Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok | Parameters | Application.

  • Select Edit | Modify.

  • Type C:\Program Files (x86)\Ngrok\ngrok.bat and select OK.

  • Select File | Exit.

  • Type sc.exe start Ngrok and press Enter.

  • Type sc.exe query Ngrok and press Enter.

  • Type exit and press Enter.

  • Restart the computer.

3.4. Forwarding of HTTP and HTTPS services

  • Logon as <User>.

  • Start Command Prompt.

  • Type ngrok 80 and press Enter.

  • Type ngrok -authtoken KSGyRwtDCw9daFbGPmtl 80 and press Enter.

  • Type ngrok -subdomain=smru 80 and press Enter.

  • Type ngrok -httpauth="helmet:12345" 80 and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              http://5423d2d7.ngrok.com -> 127.0.0.1:80
Forwarding              https://5423d2d7.ngrok.com -> 127.0.0.1:80
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms

3.5. Forwarding of SSH service

  • Logon as <User>.

  • Start Command Prompt.

  • Type ngrok -proto=tcp 22 and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              tcp://ngrok.com:58071 -> 127.0.0.1:22
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms
  • Start PuTTY.

Host Name:              ngrok.com
Port:                   58071
  • Close PuTTY.

  • Close Command Prompt.

Experimental:

  • Logon as <User>.

  • Start Command Prompt.

  • Type cp -a ~/.ngrok ~/.ngrok.orig and press Enter.

  • Type vdir ~/.ngrok* and press Enter.

  • Contents of the ~/.ngrok file.

auth_token: KSGyRwtDCw9daFbGPmtl

tunnels:
  client:
    subdomain: "smru"
    auth: "smru:********"
    proto:
      https: 80
  ssh:
    remote_port: 60701
    proto:
      tcp: 22
  • Use the level l2 password for the auth parameter.

  • Type ngrok start client ssh and press Enter.

ngrok                   (Ctrl+C to quit)

Tunnel Status           online
Version                 1.6/1.5
Forwarding              https://smru.ngrok.com -> 127.0.0.1:80
Forwarding              tcp://ngrok.com:60701 -> 127.0.0.1:22
Web Interface           127.0.0.1:4040
# Conn                  0
Avg Conn Time           0.00ms
ssh <user>@ngrok.com -p 34060