0

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 zabbix-cli@123.123.123.123 -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 zabbix-cli@123.123.123.123 -p 22

I have also tried to add the "autossh zabbix-cli@123.123.123.123 -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/)

  • It should be obvious. autossh .... isn't a absolute path. What it want is /path/to/autossh ..... Use which autossh to find the correct path to autossh. – Soren A Aug 9 '19 at 9:15
0

I got it working thanks to Soren A! The error was that I needed the absolute path, which is set when you install autossh (/usr/bin/autossh), then I had to put the parameters afterwards. I found an example here that I copied: https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.