1
0
Fork 0
medicine-config/bash_scripts/install-reverse-proxy.sh

27 lines
705 B
Bash
Executable File

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 <<EOT >> /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