Setting up Ngrok to SSH into your home network remotely. This guide will walk you through the configuration and setup of Ngrok, including running it as a system service.
- A linux host machine on your home network.
- Ngrok account and ngrok installed on your machine.
Let's start with verify the path where Ngrok is installed, use the following command
> which ngrok
/usr/local/bin/ngrok
To run Ngrok automatically on startup, create a systemd service file. This will allow Ngrok to run as a background service on your machine
sudo vim /etc/systemd/system/ngroksshtunnel.service
paste in following and change the path of ngrok in ExecStart
and <authtoken>
with your ngrok account token.
[Unit]
Description=Ngrok TCP Service for SSH
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/ngrok tcp 22
Environment="NGROK_AUTHTOKEN=<authtoken>"
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Once the service file is created, save and exit. Now, enable and start the service
sudo systemctl enable ngroksshtunnel.service
sudo systemctl start ngroksshtunnel.service
Verify it's working
> sudo systemctl status ngroksshtunnel.service
● ngroksshtunnel.service - Ngrok TCP Service for SSH
Loaded: loaded (/etc/systemd/system/ngroksshtunnel.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-12-11 13:30:32 UTC; 10min ago
Main PID: 628362 (ngrok)
Tasks: 18 (limit: 76957)
Memory: 13.5M
CGroup: /system.slice/ngroksshtunnel.service
└─628362 /usr/local/bin/ngrok tcp 22
Dec 11 13:30:32 tattoine systemd[1]: Started Ngrok TCP Service for SSH.
Now that Ngrok is running as a service, you can SSH into your home network. Go to the ngrok dashboard and under Endpoints
you should see you'r tcp connection, open a terminal window and test the connection
Example
> ssh -p 17563 user@6.tcp.eu.ngrok.io
NOTE: If necessary, forward your SSH agent in your SSH configuration.
If you'd like to support me, feel free to buy me a cup of coffee: