- Make ssh tunnel
sudo nano /etc/systemd/system/ssh-tunnel.service
- Isikan dengan isian berikut
[Unit]
Description=Persistent Reverse SSH Tunnel with PEM Key
After=network-online.target
Wants=network-online.target
[Service]
User=sky
Environment="HOME=/home/sky"
ExecStart=/usr/bin/ssh -i {server_key} -o "ServerAliveInterval=60" -o "ExitOnForwardFailure=yes" -o "StrictHostKeyChecking=no" -N -R 2222:localhost:22 {user_vps}@{ip_vps}
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
- Aktifkan Service
sudo systemctl daemon-reload
sudo systemctl enable ssh-tunnel
sudo systemctl start ssh-tunnel
- Cek statusnya
sudo systemctl status ssh-tunnel
- Pastikan SSH memungkinkan reverse tunnel dengan mengedit
/etc/ssh/sshd_config
di VPS
GatewayPorts yes
- Lalu restart SSH:
sudo systemctl restart ssh