FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt update && apt install -y \ bash \ curl \ ca-certificates \ python3 \ procps \ iproute2 \ net-tools \ coreutils \ && rm -rf /var/lib/apt/lists/* WORKDIR /root EXPOSE 7860 # Web app that shows sshx link (no auto-refresh) RUN printf '%s\n' \ 'from http.server import BaseHTTPRequestHandler, HTTPServer' \ 'import os' \ '' \ 'PORT = 7860' \ 'LINK_FILE = "/tmp/sshx_link.txt"' \ '' \ 'class Handler(BaseHTTPRequestHandler):' \ ' def do_GET(self):' \ ' self.send_response(200)' \ ' self.send_header("Content-type","text/html")' \ ' self.end_headers()' \ ' link = "Starting sshx… please refresh the page after a few seconds."' \ ' if os.path.exists(LINK_FILE):' \ ' try:' \ ' with open(LINK_FILE) as f:' \ ' t = f.read().strip()' \ ' if t:' \ ' link = t' \ ' except Exception:' \ ' pass' \ '' \ ' html = f"""' \ '' \ '' \ 'Ubuntu Hacker Space' \ '' \ '' \ '

Ubuntu Hacker Space (Educational)

' \ '

SSHX session:

' \ '
{link}
' \ '

Manual refresh • Temporary • Free tier

' \ '"""' \ ' self.wfile.write(html.encode())' \ '' \ 'HTTPServer(("0.0.0.0", PORT), Handler).serve_forever()' \ > app.py CMD ["bash","-lc", "\ set -e; \ echo '===== UBUNTU CONTAINER STARTED ====='; \ echo 'Waiting for sshx link…' > /tmp/sshx_link.txt; \ : > /tmp/sshx_raw.log; \ echo 'Installing sshx…'; \ curl -fsSL https://sshx.io/get | sh; \ echo 'Starting sshx…'; \ ( stdbuf -oL -eL sshx 2>&1 | tee -a /tmp/sshx_raw.log ) & \ echo 'Extracting sshx link…'; \ ( for i in $(seq 1 600); do \ LINK=$(grep -Eo 'https?://sshx\\.io/s/[A-Za-z0-9]+' /tmp/sshx_raw.log | tail -n1); \ if [ -z \"$LINK\" ]; then \ RAW=$(grep -Eo 'sshx\\.io/s/[A-Za-z0-9]+' /tmp/sshx_raw.log | tail -n1); \ [ -n \"$RAW\" ] && LINK=\"https://$RAW\"; \ fi; \ if [ -n \"$LINK\" ]; then \ echo \"$LINK\" | tee /tmp/sshx_link.txt; \ break; \ fi; \ sleep 1; \ done ) & \ echo 'Web UI running on :7860'; \ python3 app.py \ "]