#!/bin/bash # Start tmate in a socket echo "Starting tmate..." tmate -S /tmp/tmate.sock new-session -d # Wait for tmate to connect and get the SSH connection string echo "Waiting for tmate to generate SSH URL..." for i in {1..30}; do SSH_CONN=$(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}' 2>/dev/null) if [ -n "$SSH_CONN" ]; then echo "=============================================" echo "SSH connection string: $SSH_CONN" echo "=============================================" break fi sleep 1 done # If SSH_CONN is empty, print error if [ -z "$SSH_CONN" ]; then echo "Failed to get tmate SSH connection string." SSH_CONN="Error: Could not retrieve tmate SSH connection string." fi # Create a simple web page to display the SSH connection details cat < index.html SSH Tunnel Connection Details

SSH Access Enabled

Your Hugging Face Space Docker container is running and has established a secure tunnel via tmate.

Click below to select and copy the SSH command:

${SSH_CONN}

How to connect:

  1. Copy the command above.
  2. Paste it in your terminal and press Enter.
  3. You will have direct shell access to the Hugging Face Space container.
EOF # Start a simple Python web server to serve the page on port 7860 echo "Starting web server on port 7860..." python3 -m http.server 7860