1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25sudo pacman -S autossh
sudo useradd -m autossh
su -autossh
ssh-keygen
ssh-copy-id user@server.site
sudo vim /lib/systemd/system/autossh.service
[Unit]
Description=Auto SSH Tunnel
After=network-online.target
[Service]
User=autossh
Type=simple
ExecStart=/bin/autossh -p 22 -M 6777 -NR '*:6766:localhost:22' usera@site
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.targetq
WantedBy=graphical.target
sudo systemctl enable NetworkManager-wait-online
sudo systemctl enable autossh
sudo systemctl start autossh
It need to add hit key before start server
1 | ssh -p 6766 user@service.site |
20180616: Meet the problem to start the script
##Reference: http://arondight.me/2016/02/17/%E4%BD%BF%E7%94%A8SSH%E5%8F%8D%E5%90%91%E9%9A%A7%E9%81%93%E8%BF%9B%E8%A1%8C%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/