Best way to autostart ssh pinggy tunnels at linux startup

Hi,
I’m running debian 13 without GUI and try to find the best way to autostart pinggy ssh tunnels at startup.

I looked at systemctl services and will also look at autossh command lines.

My question is what is the proper (and simple) way of auto starting an ssh pinggy tunnel at debian startup and how to monitor and control it ? (thru log files or something else ?)

Thanks in advance for your advices !
David

P.S. I use multiple ports forwarding http tunnels.

Best way is to create a systemd service.

Here is a guide: Run Tunnel on Startup for Linux

  1. Make sure you have an ssh key (any ssh key will do). Otherwise create one using ssh-keygen
  2. Save the pinggy command (auto reconnect not required since systemd will itself handle that). Let us say we save it at ~/pinggy.sh
    #!/bin/sh
    ssh -p 443 -R0:localhost:8000 -o StrictHostKeyChecking=no -o ServerAliveInterval=30 token@pro.pinggy.io
    
    Make it executable:
    sudo chmod +x ~/pinggy.sh
  3. Create the systemd file: sudo nano /etc/systemd/system/pinggy.service
    [Unit]
    Description=Pinggy Tunnel Startup
    
    [Service]
    User=<USERNAME>
    Group=<USERNAME>
    ExecStart=/home/<USERNAME>/pinggy.sh
    Restart=on-failure
    RestartSec=10s
    
    [Install]
    WantedBy=multi-user.target
    
  4. Start it using:
    sudo systemctl daemon-reload
    sudo systemctl start pinggy.service6. 
    sudo systemctl enable pinggy.service
    
  5. See logs using:
    sudo systemctl status pinggy.service
    

Hey, thanks a lot i’ll give it a try !

Works perfectly !

David

I now moved from running tunnel from linux to docker. So far so good it’s running stable but i can’t see pinggy logs cause there are (terminal control special characters) in the logs. Is there a way of getting rid of theses terminal control chars ?

Thanks
David

Hello,
Can you please tell us how you are running it in docker? Are you running the ssh command in your own container?

For disabling the special characters, in ssh you can add the option -T. In CLI you can add the option --notui

I run it thru docker run command :

docker run -d --name=PinggyTunnel --net=host -it pinggy/pinggy -p 443 -R0:127.0.0.1:9090 -R www.service1.com:0:IP:port token@us.pro.pinggy.io -o StrictHostKeyChecking=no -o ServerAliveInterval=30 x:https

That would be cool if in the official pinggy documentation there is a docker compose file.

David

Can i use -T or --notui within docker context ?

Just a follow up. After running Pinggy Tunnel thru docker i do not recommend it. Sometimes it crash and i need to restart pinggy container. So, best way of getting a stable tunnel is thru Linux systemd method.