I need to get an Ubuntu node to start an autossh tunnel to an SSH server when the node boots.
I have created a service with the following:
' ' ' '
[Unit]
Description=Autossh tunnel at boot
After=network-online.target
[Service] Type=simple
User=root
ExecStart=/var/tmp/autossh.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
' ' ' '
The autossh.sh script found at /var/tmp contains the following:
autossh [email protected] -p 22
The error I get when I run "sudo systemctl status autossh.service" is: /etc/systemd/system/autossh.service:8: Executable path is not absolute: autossh [email protected] -p 22
I have also tried to add the "autossh [email protected] -p 22" command directly after the ExecStart command in the service.
As far as I can read on other posts is that ExecStart needs the absolute path to the script it is supposed to run, which is what I have included.
I have also tried to add both #!/bin/bash to the start of the ExecStart command, and also at the top of the autossh.sh script, but I get the same error no matter what I do.
I have also tried to place the autossh.sh script at another location (/home/username/)
autossh ....
isn't a absolute path. What it want is/path/to/autossh ....
. Usewhich autossh
to find the correct path to autossh.