Run Tunnel on Startup for Linux

To run a tunnel on Linux startup, follow these steps:

Step 1: Create a Shell Script

  1. Open a Terminal:

    • Open your terminal emulator on Linux.
  2. 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:


    Invalid CIDR Format
    Invalid CIDR Format
    Alphanumeric characters only
    • Save and exit the text editor.
  3. 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

  1. 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.

  2. 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

  1. Check Service Status:

    • Run the following command to check the status of your service:

      sudo systemctl status my-startup.service
      
    Linux System Service Status
  2. View Service Logs:

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

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