I created following service:
[Unit]
Description=Server Tunneling
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=ssh -R server-login:80:localhost:8003 serveo.net
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
Then, I ran sudo systemctl daemon-reload
followed by sudo systemctl start server-tunnels
. However, when I run sudo systemctl status server-tunnels
, it says the service failed:
server-tunnels.service - Server Tunneling
Loaded: loaded (/lib/systemd/system/server-tunnels.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2019-07-25 17:43:40 CEST; 2s ago
Process: 17139 ExecStart=/usr/bin/ssh -R server-login:80:localhost:8003 serveo.net (code=exited, status=255/EXCEPTION)
Main PID: 17139 (code=exited, status=255/EXCEPTION)
Of course, running ssh -R server-login:80:localhost:8003 serveo.net
in a normal terminal works.
Changes I made according to @kuzeyron:
[Unit]
Description=Server Tunneling
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=
ExecStart=ssh -R server-login:80:localhost:8003 serveo.net
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
Now running systemctl status server-tunnels
says it failed due to bad setting.
I'm very new to services and the Raspberry PI, so maybe I missed something obvious.
Thanks for your help!