-
create service file
# vi /usr/lib/systemd/system/myproxy.service
[Unit]
Description=SSH tunnel to proxy server
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
ExecStart=/usr/bin/ssh -NfD 1080 -i /root/.ssh/id_rsa johnson@jserver
[Install]
WantedBy=multi-user.target
-
config ssh client keepalive
# vi /etc/ssh/ssh_config
Host *
# the keepalive msg to send before disconnected
ServerAliveCountMax 2
# in seconds
ServerAliveInterval 60
-
enable service
systemctl enable myproxy.service
-
start service
systemctl start myproxy.service