Sign inSign up

mrbody/web-ssh

By mrbody

•Updated 6 months ago

Browser-based SSH terminal with real-time streaming using Go

Image
Networking
Developer tools
Web servers
0

122

mrbody/web-ssh repository overview

⁠Web SSH

A lightweight Web SSH server written in Go that allows access to remote SSH terminals directly from the browser using WebSocket.

This project bridges a WebSocket connection from the browser to an SSH session, enabling a fully interactive terminal interface in web applications.


⁠Features

  • SSH connection using password or private key
  • WebSocket real-time terminal streaming
  • Compatible with xterm.js
  • Terminal resize support
  • Streams stdin, stdout, stderr
  • High performance using Go concurrency
  • Easy deployment with Docker

⁠Architecture

Browser (xterm.js)
⬇ WebSocket
Web-SSH Server (Go)
⬇ SSH
Remote Server

The WebSocket connection acts as a bridge between the browser terminal and the SSH session.


⁠Docker Image

docker pull mrbody/web-ssh:tagname

Run the container:

docker run -p 3004:3004 mrbody/web-ssh:tagname

Server will start on:

http://localhost:3004⁠

⁠WebSocket endpoint:

ws://localhost:3004/ws

Connection Example

The first WebSocket message must be a JSON configuration containing SSH credentials:

{
  "user": "root",
  "password": "mypassword",
  "host": "example.com",
  "port": 22
}

Or using a private key:

{
  "user": "root",
  "privateKey": "-----BEGIN OPENSSH PRIVATE KEY-----...",
  "host": "example.com",
  "port": 22
}

Once authenticated, the server starts an interactive shell session.

Terminal Resize

Resize messages should be sent as JSON:

{
  "type": "resize",
  "cols": 120,
  "rows": 40
}
⁠Project Structure
.
├── main.go
├── static/
│   └── index.html
└── Dockerfile
⁠Security Notice

This project currently uses:

ssh.InsecureIgnoreHostKey()

For production environments you should implement proper host key verification.

Recommended practices:

Use HTTPS + WSS Restrict /ws access Add authentication layer Avoid exposing directly to the public internet Use Cases DevOps dashboards Remote server management panels Web-based admin consoles Educational SSH labs Container management tools

⁠Tech Stack

  • Go (Golang)
  • Gorilla WebSocket
  • crypto/ssh
  • xterm.js

Tag summary

Content type

Image

Digest

sha256:6053352ef…

Size

35.5 MB

Last updated

6 months ago

docker pull mrbody/web-ssh:beta