A modern web-based terminal emulator that enables secure remote control of your macOS terminal from any device through a web browser. Features email-based two-factor authentication, mobile optimization, and speech-to-text integration.
Full IDE experience with file explorer, terminal interface, and virtual mobile controls
Integrated AI assistance with speech-to-text capabilities powered by Groq API
- 🖥️ Full Terminal in Browser - Access zsh/bash from any device
- 📱 Mobile Optimized - Virtual keyboard and touch-friendly controls
- 🔐 Secure Authentication - Email-based one-time access codes
- ⚡ Real-time Communication - WebSocket for instant terminal response
- 🌍 Remote Access - Cloudflare Tunnel for worldwide accessibility
- 🗣️ Speech-to-Text - Voice commands powered by Groq API
- 📋 Quick Commands - Persistent command templates for efficiency
- 🔄 Auto-scaling - Adapts to screen size and orientation
- 🛡️ Security Features - Rate limiting, JWT tokens, and XSS protection
- 📁 File Explorer - Browse and manage files with real-time directory sync
- Node.js 18+
- macOS (for PTY terminal support)
- npm or yarn package manager
# Clone the repository
git clone https://github.com/your-username/terminal-to-web.git
cd terminal-to-web
# Install dependencies
npm install# Copy the example environment file
cp .env.example .env
# Edit the configuration
nano .env# Security (MUST CHANGE FOR PRODUCTION!)
JWT_SECRET=your-secret-key-minimum-32-characters
ACCESS_PASSWORD=legacy-password-for-compatibility
# Email Service (Resend API - 3000 emails/month free)
RESEND_API_KEY=re_your_resend_api_key
NOTIFICATION_EMAIL=your-email@domain.com
# Optional: Speech-to-Text (Groq API)
GROQ_API_KEY=gsk_your_groq_api_key
# Server Configuration
PORT=3000
NODE_ENV=development
MAX_LOGIN_ATTEMPTS=5
LOCKOUT_TIME_MINUTES=15
ACCESS_CODE_EXPIRY_MINUTES=10# Development (local only)
npm run dev
# Development with remote access
npm run start:dev
# Production
npm run build
npm start-
Create Account: Visit resend.com
-
Get API Key:
- Sign up for free account (3000 emails/month)
- Navigate to API Keys section
- Create new API key
- Copy the key starting with
re_
-
Configure:
RESEND_API_KEY=re_your_api_key_here NOTIFICATION_EMAIL=your-email@domain.com
-
Create Account: Visit console.groq.com
-
Get API Key:
- Sign up for free account
- Navigate to API Keys
- Create new API key
- Copy the key starting with
gsk_
-
Configure:
GROQ_API_KEY=gsk_your_groq_api_key_here
-
Install cloudflared:
# macOS brew install cloudflared # Or download from: https://github.com/cloudflare/cloudflared/releases
-
Quick Setup (Development):
npm run start:dev
This will show a public URL like:
https://random-name.trycloudflare.com -
Named Tunnel (Production):
cloudflared tunnel login cloudflared tunnel create terminal-web cloudflared tunnel route dns terminal-web terminal.yourdomain.com
- Node.js + TypeScript - Server runtime and type safety
- Express.js - Web server framework
- Socket.IO - Real-time WebSocket communication
- node-pty - PTY process management for terminal emulation
- JWT - Secure authentication tokens
- Resend/Nodemailer - Email service for 2FA codes
- Vanilla JavaScript - Lightweight client-side code
- xterm.js - Terminal emulation in browser
- Socket.IO Client - Real-time communication
- Responsive CSS - Mobile-optimized interface
src/
├── server.ts # Main Express server + Socket.IO
├── config.ts # Configuration with validation
├── terminalHandler.ts # Terminal event handling
├── services/ # Business logic layer
│ ├── TerminalManager.ts # PTY process management
│ ├── AccessCodeService.ts # 2FA code generation/validation
│ ├── CommandService.ts # Persistent command storage
│ ├── ResendEmailService.ts # Email service (primary)
│ ├── EmailService.ts # Gmail SMTP fallback
│ └── SpeechService.ts # Speech-to-text integration
├── middleware/ # Express/Socket.IO middleware
│ ├── auth.ts # JWT authentication
│ └── errorHandler.ts # Error handling
└── utils/ # Utility functions
├── security.ts # Rate limiting & security
├── validation.ts # Input validation & XSS protection
└── logger.ts # Structured logging
public/
├── index.html # Authentication interface
├── terminal.html # IDE interface with file explorer
├── app.js # Authentication logic
├── ide-app.js # IDE and terminal functionality
└── style.css # Responsive styles
- Rate Limiting: 5 authentication attempts per IP per 15 minutes
- JWT Tokens: 24-hour expiration with secure signing
- Access Codes: 6-digit codes with 10-minute expiry
- Input Validation: XSS protection and data sanitization
- Environment Filtering: Secure PTY process environment
- IP Tracking: Progressive lockout with exponential backoff
-
Change Default Secrets:
# Generate random JWT secret openssl rand -base64 32 -
Configure CORS:
CORS_ORIGIN=https://yourdomain.com,https://anotherdomain.com
-
Use HTTPS: Cloudflare Tunnel provides automatic HTTPS
-
Monitor Logs: All events are logged in structured format
- ✅ iPhone/iPad (Safari, Chrome)
- ✅ Android (Chrome, Firefox)
- ✅ Desktop browsers (all modern browsers)
- Virtual Controls: Ctrl/Alt/Tab/Esc buttons for mobile users
- Arrow Keys: Dedicated navigation panel
- Quick Commands: Persistent localStorage-based shortcuts
- Responsive Design: Font sizing adapts to device orientation
- Touch Support: Integrated virtual keyboard
- Speech Input: Voice-to-text command entry
- Open the web application (local or public URL)
- Click "📧 Request Access Code"
- Enter your email address
- Check email for 6-digit access code
- Enter code and click "🔐 Login"
- Access granted for 24 hours
- Desktop: Works like a native terminal
- Mobile Controls:
Ctrl/Alt/Tab/Esc: Virtual modifier keys↑↓←→: Arrow key navigationCMD: Quick commands panel[ ]: Fullscreen toggle🎤: Speech-to-text input
- Click the microphone button (🎤) in the terminal
- Speak your command
- Command is automatically transcribed and entered
- Supports multiple languages with auto-detection
- Click the
CMDbutton - Add new command with
+button - Enter command and description
- Use for rapid command execution
# Development
npm run dev # Server with hot reload
npm run start:dev # Server + Cloudflare tunnel
npm run start:all # Build + server + tunnel
# Production
npm run build # Compile TypeScript
npm start # Run production build
# Code Quality
npm run lint # ESLint check
npm run lint:fix # Auto-fix linting issues
npm run format # Prettier formatting
npm run typecheck # TypeScript type checking-
Server Preparation (Ubuntu/Debian):
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs -
Application Setup:
git clone https://github.com/your-username/terminal-to-web.git cd terminal-to-web npm install npm run build -
Systemd Service:
[Unit] Description=TerminalFlow After=network.target [Service] Type=simple User=www-data WorkingDirectory=/path/to/terminal-to-web ExecStart=/usr/bin/node dist/server.js Restart=always Environment=NODE_ENV=production [Install] WantedBy=multi-user.target
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]# macOS
xcode-select --install
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install- Code not received: Check RESEND_API_KEY in .env
- Invalid code: Codes expire after 10 minutes
- Rate limiting: Wait 15 minutes or restart server
# Check tunnel status
cloudflared tunnel list
# Restart tunnel
pkill cloudflared
npm run start:dev- Ensure server is running on correct port
- Check browser console for error messages
- Verify JWT token validity
- Clear browser localStorage if needed
Without email configuration, access codes are displayed in server console:
============================================================
🖥️ TERMINAL ACCESS CODE
============================================================
📧 Email: your-email@domain.com
🔐 CODE: 123456
⏰ Valid for: 10 minutes
============================================================curl http://localhost:3000/healthAll events are logged in JSON format:
{
"level": "info",
"message": "Access code created",
"email": "user@domain.com",
"ip": "192.168.1.1",
"timestamp": "2024-01-01T12:00:00Z"
}- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
npm run lint && npm run typecheck - Commit changes:
git commit -m "feat: description" - Push to branch:
git push origin feature-name - Create Pull Request
- Use TypeScript for all backend code
- Follow ESLint and Prettier configurations
- Write descriptive commit messages
- Add tests for new features
- Update documentation as needed
ISC License - see LICENSE file for details.
- CLAUDE.md - Technical documentation for developers
- SECURITY_IMPROVEMENTS.md - Security enhancements
- REMOTE_ACCESS.md - Remote access configuration
When reporting issues, please include:
- Detailed problem description
- Server logs (if applicable)
- Node.js version and operating system
- Steps to reproduce the issue
- Expected vs actual behavior
⚡ Quick Start: npm install && npm run start:dev - Your terminal accessible from anywhere in the world!