• 0 Posts
  • 3 Comments
Joined 1 year ago
cake
Cake day: July 17th, 2024

help-circle


  • I just use autossh for it.

    I run an ssh connection to a VPS I pay like $5, which forwards a port there. The screen in the following command isn’t required, but I have it so I don’t have to keep the terminal window open.

    screen -d -m -S autossh.eastusa.keepalive autossh -M 33333 -R VPS_IP_HERE:5555:localhost:22 root@VPS_IP_HERE
    

    Then from other computers, to connect back

    ssh -L 5555:localhost:5555 root@VPS_IP_HERE
    ssh root@localhost -p 5555
    

    For remote computers connecting back, the first ssh connects to the VPS and forwards a port to the remote computer. Then the 2nd ssh connection uses the forwarded port to complete the ssh connection to the computer behind the IP that can’t port forward.