Philipp's Computing Blog

Success is about speed and efficiency

Start AutoSSH on System Startup Using Systemd on Arch Linux

OK, here is how to start ssh on system startup (this is the content of the systemd .service configuration file /etc/systemd/system/autossh.service):

[Unit]
Description=AutoSSH service for a reverse tunnel from some.example.com to localhost
After=network.target

[Service]
ExecStart=/usr/bin/autossh -M 0 -q -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" someuser@some.example.com -R 1250:localhost:8080

[Install]
WantedBy=multi-user.target

After creating the systemd .service file do:

systemctl daemon-reload
systemctl status autossh.service
systemctl restart autossh.service
#Enable autossh.service to be started on bootup:
systemctl enable autossh.service

Resources