Fabio Alessandro Locati 4b1c7e8
The autossh systemd service uses configuration files from the
Fabio Alessandro Locati 4b1c7e8
/etc/autossh directory. Each configuration file should define a single
Fabio Alessandro Locati 4b1c7e8
variable OPTIONS, which contains all command line options to pass to
Fabio Alessandro Locati 4b1c7e8
the respective autossh service instance. The configuration file is the
Fabio Alessandro Locati 4b1c7e8
name of the service instance suffixed with .conf, for example
Fabio Alessandro Locati 4b1c7e8
autossh@myconnection.service loads its configuration from the
Fabio Alessandro Locati 4b1c7e8
/etc/autossh/myconnection.conf file. For example (all on one line,
Fabio Alessandro Locati 4b1c7e8
wrapped here for readability):
Fabio Alessandro Locati 4b1c7e8
Fabio Alessandro Locati 4b1c7e8
    OPTIONS=-M 0 -NT
Fabio Alessandro Locati 4b1c7e8
        -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3"
Fabio Alessandro Locati 4b1c7e8
        -l autossh -i /path/to/id_rsa -L 7474:127.0.0.1:7474
Fabio Alessandro Locati 4b1c7e8
        srv.example.com
Fabio Alessandro Locati 4b1c7e8
Fabio Alessandro Locati 4b1c7e8
Note that it is not necessary to configure everything related to the
Fabio Alessandro Locati 4b1c7e8
actual connection in $OPTIONS, instead just as with regular ssh(1)
Fabio Alessandro Locati 4b1c7e8
use, the -F option can be used there to load them from separate
Fabio Alessandro Locati 4b1c7e8
configuration files. For example:
Fabio Alessandro Locati 4b1c7e8
Fabio Alessandro Locati 4b1c7e8
    OPTIONS=-M 0 -N -F /path/to/myconnection_ssh_config srv.example.com
Fabio Alessandro Locati 4b1c7e8
Fabio Alessandro Locati 4b1c7e8
The services run as the autossh user by default. This means that
Fabio Alessandro Locati 4b1c7e8
functionality requiring root access, for example forwarding local
Fabio Alessandro Locati 4b1c7e8
privileged ports, is not available to them. If root functionality is
Fabio Alessandro Locati 4b1c7e8
required, it can be accomplished through the systemd unit override
Fabio Alessandro Locati 4b1c7e8
mechanisms, see systemd.unit(5).