Skip to content

saf-all/ssh-terminal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSH Terminal Web Interface

A modern, web-based SSH terminal accessible from any browser. Built with Flask, Socket.IO, and xterm.js.

SSH Terminal Python Socket.IO

Features

  • 🔐 Secure Authentication - Login required before accessing terminal
  • 🖥️ Full Terminal Emulation - Powered by xterm.js with modern UI
  • Real-time SSH - WebSocket-based live terminal streaming
  • 🎨 Modern Design - Clean, minimal interface with dark theme
  • 📱 Responsive - Works on desktop and mobile browsers
  • 🔓 Session Management - Multiple concurrent sessions supported

Screenshots

Terminal Interface

Quick Start

1. Install Dependencies

cd ssh-terminal
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Run the Application

python app.py

The server will start on http://localhost:5002

3. Login

  • Username: admin
  • Password: admin123

4. Connect

Enter your SSH credentials (username/password) to connect to your server.

Configuration

Change Login Credentials

Edit app.py:

if username == 'admin' and password == 'admin123':

Change Port

python app.py --port 5002

Or edit app.py:

socketio.run(app, host='0.0.0.0', port=5002)

Cloudflare Tunnel Setup

To expose via Cloudflare Tunnel:

# ~/.cloudflared/config.yml
tunnel: your-tunnel-name
ingress:
  - hostname: ssh.safalpanta.com
    service: http://localhost:5002

Deployment with Gunicorn

pip install gunicorn

gunicorn -w 2 -b 0.0.0.0:5002 "app:app"

Systemd Service

Create /etc/systemd/system/ssh-terminal.service:

[Unit]
Description=SSH Terminal Web App
After=network.target

[Service]
Type=simple
User=saf
WorkingDirectory=/var/www/safalpanta.com/ssh-terminal
ExecStart=/var/www/safalpanta.com/ssh-terminal/venv/bin/python app.py
Restart=always

[Install]
WantedBy=multi-user.target

Security Notes

⚠️ Important: This is a development/demo implementation.

For production use:

  1. Use HTTPS - Always serve over HTTPS
  2. Strong Authentication - Use environment variables for credentials
  3. Rate Limiting - Add rate limiting to prevent brute force
  4. Session Timeout - Implement automatic session expiration
  5. IP Whitelisting - Restrict access to known IPs
  6. Two-Factor Auth - Consider adding 2FA

Tech Stack

  • Backend: Flask, Flask-SocketIO, paramiko
  • Frontend: xterm.js, Socket.IO client, vanilla JavaScript
  • Styling: Custom CSS with modern design system

File Structure

ssh-terminal/
├── app.py                 # Flask app & WebSocket handlers
├── requirements.txt       # Python dependencies
├── README.md             # This file
├── static/
│   ├── css/
│   │   └── style.css     # Main stylesheet
│   └── js/
│       └── terminal.js   # Terminal logic
└── templates/
    ├── login.html        # Login page
    └── terminal.html     # Terminal interface

Troubleshooting

"Connection refused"

  • Make sure SSH server is running: sudo systemctl status sshd

"Permission denied"

  • Check SSH credentials
  • Verify SSH key permissions if using keys

Terminal not rendering

  • Check browser console for errors
  • Ensure JavaScript is enabled
  • Clear browser cache

License

MIT License - feel free to use and modify.

Author

Safal Panta - safalpanta.com

About

Web-based SSH terminal with xterm.js and Socket.IO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors