set -e apt install --assume-yes autossh ssh-keygen -f ~/.ssh/proxy-server ssh-copy-id -i ~/.ssh/proxy-server.pub -p 22 proxy_user@188.225.79.4 read -p "Enter port for proxy server: " proxy_port cat <> /etc/systemd/system/remote-autossh.service [Unit] Description=AutoSSH service for remote tunnel After=network-online.target Wants=network-online.target systemd-networkd-wait-online.service [Service] User=root Restart=on-failure RestartSec=1min ExecStart=/usr/bin/autossh -N -R $proxy_port:localhost:22 -i /root/.ssh/proxy-server proxy_user@188.225.79.4 [Install] WantedBy=multi-user.target EOT systemctl daemon-reload && systemctl start remote-autossh systemctl enable remote-autossh.service