Browser-based SSH terminal with real-time streaming using Go
122
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.
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 pull mrbody/web-ssh:tagname
Run the container:
docker run -p 3004:3004 mrbody/web-ssh:tagname
Server will start on:
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
}
.
├── main.go
├── static/
│ └── index.html
└── Dockerfile
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
Content type
Image
Digest
sha256:6053352ef…
Size
35.5 MB
Last updated
6 months ago
docker pull mrbody/web-ssh:beta