systemd autossh.service variables

439 views Asked by At

I want to add a systemd service file for autossh to my system. This skript should ask some viables from a conf-file. This is what I tried until now:

autossh.service:

[Unit]
Description=autossh
After=network.target

[Service]
Type=simple
EnvironmentFile=/usr/local/etc/autossh.conf
ExecStart=/usr/bin/autossh -M 0 -g -C -2 -N -i /home/$TUNNEL_USER/.ssh/id_rsa $TUNNEL_USER@$SERVER_NAME -p $DEST_SSH_PORT -L $LOCAL_PORT:localhost:$DEST_PORT &
Restart=always
RestartSec=60

[Install]
WantedBy=multi-user.target 

autossh.conf:

TUNNEL_USER=tunneluser
SERVER_NAME=host.example.com
LOCAL_PORT=10001
DEST_PORT=5001
DEST_SSH_PORT=22

Unfortunately the variables are not resolved properly. I tried double quoting "" and things like %{LOCAL_PORT} also.

0

There are 0 answers