Skip to content

Instantly share code, notes, and snippets.

@rahman541
Forked from ArrEssJay/env.conf
Last active August 31, 2021 04:34
Show Gist options
  • Save rahman541/f009cb9e06634befe1eeeb9327fbed4e to your computer and use it in GitHub Desktop.
Save rahman541/f009cb9e06634befe1eeeb9327fbed4e to your computer and use it in GitHub Desktop.
ngrok / ngrok2 systemd script + config
cd ~
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip -P ~
unzip ngrok-stable-linux-amd64.zip
sudo mv ngrok /usr/local/bin/
# To test out ngrok ssh background
ngrok tcp 22 --log=stdout > ~/ngrok.log &
# To copy token goto: https://dashboard.ngrok.com/get-started
ngrok authtoken ...
nano ~/.ngrok2/ngrok.yml
sudo nano /lib/systemd/system/ngrok.service.d/env.conf
sudo nano /lib/systemd/system/ngrok.service
sudo systemctl start ngrok
sudo systemctl enable ngrok
sudo systemctl status ngrok
# /lib/systemd/system/ngrok.service.d/env.conf
[Service]
#which tunnel, or all?
Environment="TUNNEL=--all"
#log format
Environment="LOG_FORMAT=logfmt"
#log level
Environment="LOG_LEVEL=info"
#log file
Environment="LOG=/var/log/ngrok.log"
#ngrok2 config file (for tunnels/certs etc.)
#adjust home directory accordingly
Environment="CONFIG=/home/ubuntu/.ngrok2/ngrok.yml"
# Ubuntu: /lib/systemd/system/ngrok.service
# Config (env.conf) placed in ngrok.service.d will be read automatically
# YMMV on other distributions
[Service]
PrivateTmp=true
Type=simple
StandardOutput=journal
StandardError=journal
ExecStart=/usr/local/bin/ngrok start ${TUNNEL} --log-format ${LOG_FORMAT} --log-level ${LOG_LEVEL} --log ${LOG} --config ${CONFIG}
Restart=always
[Install]
WantedBy=multi-user.target
# ~/.ngrok2/ngrok.yml
region: ap
tunnels:
ssh:
proto: tcp
addr: 2828
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment