Autostart of SSH Tunel on RPi Docker

Hello,

RPi Docker
i have made HA work behind Nat with SSH Tunel.
The only problem is autostart of if.

If i start a command from RPi’s CLI
ssh -p 22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -N -R 31281:localhost:8123 [email protected]
Tunnel works perfect.

I created a file /etc/systemd/system/ha-tunnel.service

[Unit]
Description=Tunnel for HA
After=network.target

[Service]
ExecStart=/usr/bin/ssh -p 22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -N -R 31281:localhost:8123 [email protected]

RestartSec=5
Restart=always

[Install]
WantedBy=multi-user.target

And then try to start it with

sudo systemctl start ha-tunnel

and it do not starts.

Staus shows me

 Loaded: loaded (/etc/systemd/system/ha-tunnel.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2020-08-12 01:08:24 BST; 3s ago
  Process: 10634 ExecStart=/usr/bin/ssh -p 22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60
 Main PID: 10634 (code=exited, status=255/EXCEPTION)

What have i’ve done wrong?

Thanks a lot!

I have solved it.

Just need to add some lines.
Here is the final version that works perfect!

[Unit]
Description=Tunnel for HA
ConditionPathExists=|/usr/bin
After=network.target

[Service]
User=pi
ExecStart=/usr/bin/ssh -i "/home/pi/.ssh/id_rsa" -p 22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -N -R 31281:localhost:8123 [email protected]

RestartSec=5s
Restart=always

[Install]
WantedBy=multi-user.target

Why not use autossh instead.

If i could know about it…