#/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
다시 시작한 후
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
ssh exited with error status 255
터널을 통해서는 닿을 수 없으니까user@domain
ssh -R 2255:localhost:22 user@domain
그리고
/usr/bin/autossh -M 0 -f -N -R 2255:localhost:22 user@domain -g -o ServerAliveInterval=60 -o ServerAliveCountMax=3
잘 작동합니다. 두 컴퓨터 간에 지속적인 연결을 원합니다.
시도했지만 Type=simple
결국 얻었습니다.Active: inactive (dead)