1. Make ssh tunnel
    sudo nano /etc/systemd/system/ssh-tunnel.service
  2. 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
    
  3. Aktifkan Service
    sudo systemctl daemon-reload
    sudo systemctl enable ssh-tunnel
    sudo systemctl start ssh-tunnel
  4. Cek statusnya
    sudo systemctl status ssh-tunnel
  5. Pastikan SSH memungkinkan reverse tunnel dengan mengedit /etc/ssh/sshd_config di VPS
    GatewayPorts yes
  6. Lalu restart SSH:
    sudo systemctl restart ssh

Leave a Reply

Your email address will not be published. Required fields are marked *