Run Tunnel on Startup for Linux
To run a tunnel on Linux startup, follow these steps:
Prerequisite
Generate an ssh key, if you don’t have one already.
- In your terminal / command prompt run:
ssh-keygen
- Press Enter key (Return key) till the command finishes.
This is necessary to skip the password input of the ssh command.
Step 1: Create a Shell Script
Open a Terminal:
- Open your terminal emulator on Linux.
Create a Shell Script:
Use a text editor to create a shell script. For example, you can use nano
:
sudo nano /usr/local/sbin/my-startup.sh
Paste your Pinggy command into the script. For example:
#!/bin/sh
ssh -p 443 -R0:localhost:8000 -o StrictHostKeyChecking=no
-o ServerAliveInterval=30 a.pinggy.io
You can customize the command here:
- Save and exit the text editor.
Make the Script Executable:
- Run the following command to make your script executable:
sudo chmod +x /usr/local/sbin/my-startup.sh
Step 2: Create a Systemd Service
Create a Systemd Service File:
Use a text editor to create a systemd service file. For example:
sudo nano /etc/systemd/system/my-startup.service
Paste the following content into the file:
[Unit]
Description=Pinggy Tunnel Startup
[Service]
ExecStart=/usr/local/sbin/my-startup.sh
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
Save and exit the text editor.
Reload Systemd and Enable the Service:
- Run the following commands to reload systemd and enable your service:
sudo systemctl daemon-reload
sudo systemctl enable my-startup.service
Step 3: Verify and Monitor the Service
Check Service Status:

View Service Logs:
- Use the following command to view the logs of your service:
sudo journalctl -u my-startup.service

Now, your Pinggy tunnel will automatically execute each time your Linux system starts up.