🔐 Control OpenTTY from other devices
Lima edited this page 2025-10-20 10:35:54 -03:00

🔗 bind Command

📖 Overview

The bind command creates a TCP server that listens on a specified port, allowing remote clients to connect and execute commands on the OpenTTY device.

📝 Syntax

bind <port> [shell] [process_name]

⚙️ Parameters

  • port: The port number to listen on (1-65535)
  • shell (optional): A command prefix to prepend to all received commands
  • process_name (optional): Custom name for the background process (default: "bind")

💡 Usage Examples

# Basic bind server on port 8080
bind 8080

# Bind with command prefix
bind 9090 "echo Remote:"

# Bind with custom process name
bind 7070 "" "my-server"

🔧 How It Works

  1. Server Creation: Opens a TCP server socket on the specified port
  2. Client Handling: Accepts incoming connections (No authenticates clients, everyone can connect and send commands)
  3. Command Execution: Forwards received commands to OpenTTY's shell
  4. Output Return: Sends command output back to the connected client
  5. Session Management: Maintains multiple client sessions simultaneously

Features

  • Background process execution
  • Multiple concurrent connections
  • Command preprocessing with prefix
  • Session tracking and management
  • Automatic cleanup on disconnect

🛠️ Process Management

# View active bind sessions
ps
who

# Terminate specific bind process
kill <PID>

# Stop all bind processes
stop bind

🌐 WebProxy Package

📋 Package Information

  • Name: WebProxy
  • Description: Global Bind proxy service
  • Requirements: OpenTTY 1.16+ and Lua Runtime

📥 Installation

You can install WebProxy with the default Package Manager of OpenTTY, use yang and select package WebProxy. It will install at /bin/shprxy

🚀 Usage

# Start WebProxy (prompts for password)
shprxy

# Or with password pre-stored
shprxy your_password

🔄 How WebProxy Works

  1. Authentication: Connects to the official WebProxy service using a password
  2. Session Creation: Establishes a secure session with unique ID
  3. Command Relay: Forwards commands from the web interface to your OpenTTY device
  4. Output Streaming: Returns command results to the web client in real-time

🌍 Web Interface

Default Instance: http://opentty.xyz/cli

The web interface provides:

  • 🔐 Secure login with session ID and password
  • 💻 Web-based terminal emulator
  • 📱 Mobile-friendly interface
  • 🔄 Real-time command execution
  • 👥 Multiple session support

📚 Official Repository

For server implementation details and self-hosting options, visit: https://github.com/mrlima4095/pproxy

🔒 Security Features

  • Password-protected sessions
  • Session isolation
  • Automatic timeout handling
  • Encrypted communication (when available)
  • Connection validation

📋 Example Workflow

# Start WebProxy in background
lua /bin/shprxy mysecurepassword &

# WebProxy will display:
# WebProxy ID: a1b2c3d4

# Use the web interface at:
# http://opentty.xyz/cli
# Login with ID: a1b2c3d4 and password: mysecurepassword

Process Commands

# Check WebProxy status
ps | grep web-proxy

# View WebProxy connection informations
trace view <web-proxy-PID>

# Stop WebProxy
kill <web-proxy-PID>

🎯 Conclusion

The WebProxy package enables remote access to your OpenTTY device through a web interface, making it ideal for managing devices over the internet or sharing temporary access with others.