Starting Ngrok Automatically at Boot Using Upstart

Tags: May 19, 2016 6:41 PM


Expose SSH of the local machine to the internet using service provided by


First thing first create an account at so we can get the Auth Token and also can monitor the tunnel created and know the address of the tunnel. Next is create a configurion file under ~/.ngrok2/ngrok.yml to store the token. You can get this token on your Ngrok dashboard.

$ cat > ~/.ngrok2/ngrok.yml
Then create new file called ngrok.conf in /etc/init. Assuming the location of the ngrok binary is on /opt/ngrok/ngrok.
$ cat > /etc/init/ngrok.conf
# Ngrok
# Create tunnel provided by

description "Ngrok Tunnel"

start on runlevel [2345]
stop on runlevel [!2345]

respawn limit 10 5
umask 022

exec /opt/ngrok/ngrok tcp 22

To start the daemon manually issue following command.

$ sudo service ngrok start
$ ps aux|grep ngrok
root       712  0.1  0.6 420044 13200 ?        Ssl  13:22   0:28 /opt/ngrok/ngrok tcp 22
root      2927  0.0  0.0  11740   936 pts/0    S+   19:36   0:00 grep --color=auto ngrok

Go to your Ngrok dashboard and see the status of your tunnel. Normally ngrok will give you address something like tcp:// where XYZ is port number that mapped to your local port. So to connect via SSH we can point to that address and the given port.

$ ssh -p XYZ

Share on Facebook Twitter


Post a Comment