systemd:autossh 服务处于活动状态,但 ssh 退出时出现错误

systemd:autossh 服务处于活动状态,但 ssh 退出时出现错误
#/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)

相关内容