#/lib/systemd/system/autossh.service
[Unit]
Description=Auto Reverse SSH
Requires=systemd-networkd-wait-online.service
After=systemd-networkd-wait-online.service
[Service]
Type=forking
ExecStart=/usr/bin/autossh -M 0 -f -N -R 2255:localhost:22 user@domain -g -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes
[Install]
WantedBy=multi-user.target
Após a reinicialização
sudo systemctl status autossh.service
● autossh.service - Auto Reverse SSH
Loaded: loaded (/lib/systemd/system/autossh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-01-17 00:05:15 -03; 5min ago
Process: 807 ExecStart=/usr/bin/autossh -M 0 -f -N -R 2255:localhost:22 user@domain -g -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes (code=exited, status=0/SUCCESS)
Main PID: 815 (autossh)
CGroup: /system.slice/autossh.service
└─815 /usr/lib/autossh/autossh -M 0 -N -R 2255:localhost:22 user@domain -g -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes
Jan 17 00:06:28 raspberrypi autossh[815]: ssh exited with error status 255; restarting ssh
Jan 17 00:07:00 raspberrypi autossh[815]: starting ssh (count 10)
Jan 17 00:07:00 raspberrypi autossh[815]: ssh child pid is 2166
Jan 17 00:07:01 raspberrypi autossh[815]: ssh exited with error status 255; restarting ssh
Jan 17 00:07:51 raspberrypi autossh[815]: starting ssh (count 11)
Jan 17 00:07:51 raspberrypi autossh[815]: ssh child pid is 2188
Jan 17 00:07:53 raspberrypi autossh[815]: ssh exited with error status 255; restarting ssh
Jan 17 00:09:05 raspberrypi autossh[815]: starting ssh (count 12)
Jan 17 00:09:05 raspberrypi autossh[815]: ssh child pid is 2213
Jan 17 00:09:05 raspberrypi autossh[815]: ssh exited with error status 255; restarting ssh
Por causa de ssh exited with error status 255
, não consigo fazer o túnel para user@domain
ssh -R 2255:localhost:22 user@domain
e
/usr/bin/autossh -M 0 -f -N -R 2255:localhost:22 user@domain -g -o ServerAliveInterval=60 -o ServerAliveCountMax=3
funciona bem, eu só quero fazer uma conexão persistente entre dois computadores.
Eu tentei Type=simple
, mas recebi Active: inactive (dead)
Tags autossh systemd-nspawn