Last active
March 4, 2019 05:43
-
-
Save pzxbc/89d49f77e6ccf5c147990ed3d45aabd3 to your computer and use it in GitHub Desktop.
autossh systemd service unit file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=autossh connect | |
After=network-online.target ssh.service | |
[Service] | |
ExecStart=/usr/bin/autossh -M 40000 -N -q pi3 | |
ExecStop=killall -s KILL autossh | |
RestartSec=5 | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
ssh config for pi3
Host pi3
HostName xxx.com
Port 22
User pi
ServerAliveInterval 60
GatewayPorts yes
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
RemoteForward *:8080 localhost:22
StrictHostKeyChecking no
IdentityFile ~/.ssh/id_rsa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
autossh 自动连接的systemd服务配置文件
需要在.ssh目录下配置对应的ssh连接选项
配置文件存放于
/lib/systemd/system
目录下编辑完成后,使用下面命令生效
sudo systemctl daemon-reload sudo systemctl enable autossh_connect.service sudo systemctl start autossh_connect.service