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
1.1. Client Installation
-
Install Apache.
-
Install PHP.
-
Log in as <user>.
-
Start Terminal.
-
Type
cd ~/Downloadsand 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/ngrokand press Enter. -
Type
vdir /etc/ngrokand press Enter. -
Type
sudo a2enmod ssland press Enter. -
Type
sudo service apache2 restartand press Enter. -
Type
sudo ngrok -config=/etc/ngrok -log=none start client sshand press Enter. -
Close Terminal.
-
Start Browser.
-
Connect to http://<hostname>.smru.ngrok.com.
User Name: smru Password: ********
-
Click OK.
-
Close Browser.
-
Start PuTTY.
-
Connect to http://ngrok.com:60301.
-
Close PuTTY.
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/ngrokand press Enter. -
Type
sudo chmod a+x /etc/init.d/ngrokand press Enter. -
Make the following changes (see below) to the /etc/init.d/ngrok file.
-
Type
diff /etc/init.d/skeleton /etc/init.d/ngrokand 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 runleveland press Enter. -
Type
vdir /etc/rc2.dand press Enter. -
Type
sudo update-rc.d ngrok defaultsand press Enter. -
Type
vdir /etc/rc2.dand press Enter.
S22ngrok -> ../init.d/ngrok
-
Close Terminal.
-
Restart the computer.
-
Log in as <user>.
-
Start Terminal.
-
Type
ps ax | grep -i ngrokand press Enter. -
Type
sudo service ngrok statusand press Enter. -
Optional: Type
sudo service ngrok stopand press Enter. -
Optional: Type
sudo service ngrok startand press Enter. -
Optional: Type
sudo service ngrok restartand press Enter. -
Close Terminal.
1.4. Forwarding of HTTP services
-
Log in as <user>.
-
Start Terminal.
-
Type
ngrok 80and press Enter. -
Type
ngrok -authtoken KSGyRwtDCw9daFbGPmtl 80and press Enter. -
Type
ngrok -subdomain=smru 80and press Enter. -
Type
ngrok -httpauth="helmet:12345" 80and 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
-
Start Browser.
-
Connect to http://localhost:4040.
-
Connect to http://5423d2d7.ngrok.com.
-
Connect to http://smru.ngrok.com.
-
Close Browser.
-
Close Terminal.
1.5. Forwarding of SSH service
-
Log in as <user>.
-
Start Terminal.
-
Type
ngrok -proto=tcp 22and 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 sshand 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 ngrokand press Enter. -
Type
ngrok versionand press Enter. -
Type
ngrok helpand 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
-
Note: See http://nssm.cc/description.
-
See also https://github.com/inconshreveable/ngrok/issues/160.
-
Install Microsoft Windows Server 2003 Resource Kit Tools.
-
Logon as Administrator.
-
Contents of the C:\Program Files (x86)\ngrok\ngrok.bat file.
@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 Ngrokand press Enter. -
Optional: Type
instsrv.exe Ngrok removeand press Enter. -
Type
instsrv.exe Ngrok "C:\Program Files (x86)\Windows Resource Kits\Tools\srvany.exe"and press Enter. -
Type
regeditand press Enter. -
Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok.
-
Select Edit | New | Key and type
Parametersand press Enter. -
Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok | Parameters.
-
Select Edit | New | String Value and type
Applicationand press Enter. -
Select HKLM | SYSTEM | CurrentControlSet | services | Ngrok | Parameters | Application.
-
Select Edit | Modify.
-
Type
C:\Program Files (x86)\Ngrok\ngrok.batand select OK. -
Select File | Exit.
-
Type
sc.exe start Ngrokand press Enter. -
Type
sc.exe query Ngrokand press Enter. -
Type
exitand press Enter. -
Restart the computer.
3.4. Forwarding of HTTP and HTTPS services
-
Logon as <User>.
-
Start Command Prompt.
-
Type
ngrok 80and press Enter. -
Type
ngrok -authtoken KSGyRwtDCw9daFbGPmtl 80and press Enter. -
Type
ngrok -subdomain=smru 80and press Enter. -
Type
ngrok -httpauth="helmet:12345" 80and 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
-
Start Browser.
-
Connect to http://localhost:4040.
-
Connect to http://5423d2d7.ngrok.com.
-
Connect to https://5423d2d7.ngrok.com.
-
Connect to http://smru.ngrok.com.
-
Close Browser.
-
Close Command Prompt.
3.5. Forwarding of SSH service
-
Logon as <User>.
-
Start Command Prompt.
-
Type
ngrok -proto=tcp 22and 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.origand 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 sshand 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
-
Start Browser.
-
Connect to https://smru.ngrok.com.
-
Close Browser.
-
Start PuTTY.
-
Connect to http://ngrok.com:60701.
-
Close PuTTY.
-
Close Command Prompt.
ssh <user>@ngrok.com -p 34060