Skip to content

Instantly share code, notes, and snippets.

@acalatrava
Last active November 13, 2024 15:35
Show Gist options
  • Save acalatrava/6f84a2c83d9233e36004d8a30179f077 to your computer and use it in GitHub Desktop.
Save acalatrava/6f84a2c83d9233e36004d8a30179f077 to your computer and use it in GitHub Desktop.
SSH over WebSockets

SSH over WebSocket

Stuck behind restrictive firewalls or deep packet inspection? This project lets you tunnel SSH connections through WebSockets, bypassing most limitations on standard SSH ports.


Why This Project Exists

While receiving treatment in the hospital, I encountered a common problem: restricted internet access with only hospital Wi-Fi available, and a firewall blocking SSH (even on port 443). They were also using Deep Packet Inspection, preventing SSH traffic over non-standard ports.

So, I built this tool. Simply run the provided Docker Compose, and you’ll be able to tunnel SSH through WebSockets—no more blocked SSH sessions!


How to Use It

  1. On the server run this command (or use the docker compose file and execute docker compose up -d):

    docker run -d --name gost \
     -p 80:8080 \
     -p 443:8443 \
     ginuerzh/gost:2.11.5 \
     -L=wss://:8443 \
     -L=ws://:8080 \
     -F=forward+tcp://172.17.0.1:22
  2. On the client, execute:

    gost -L "tcp://:2222" -F "wss://<YOUR_REMOTE_IP>:443"
  3. Connect via SSH in another terminal:

    ssh -p 2222 root@localhost

And that’s it—you're connected! 🎉


Enjoy secure and flexible SSH, even in restricted environments!

services:
gost:
image: ginuerzh/gost:2.11.5
command: >
-L=wss://:8443
-L=ws://:8080
-F=forward+tcp://172.17.0.1:22 # this will forward connection to main host from docker, aka localhost. Change it to your desired destination if different.
ports:
- 80:8080
- 443:8443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment