[Unit] Description=autossh 隧道:本机 127.0.0.1:13306 → doorcome.cn:3306(MySQL) Documentation=file:///home/pi/project/xwlb/autossh.sh After=network-online.target Wants=network-online.target [Service] User=pi Group=pi # 让 autossh 在首次连接失败时也持续重试,而不是直接退出 Environment=AUTOSSH_GATETIME=0 ExecStart=/usr/bin/autossh -M 0 -N \ -o ServerAliveInterval=30 -o ServerAliveCountMax=3 \ -o ExitOnForwardFailure=yes \ -L 13306:localhost:3306 tunnel@doorcome.cn Restart=always RestartSec=10 SyslogIdentifier=xwlb-tunnel [Install] WantedBy=multi-user.target