Web-based interactive terminal emulator that allows users to easily record, share, and replay console sessions.
Go to file
2022-01-07 11:13:42 -05:00
assets Update README.md 2022-01-07 11:13:42 -05:00
extra support self-signed cert 2022-01-07 09:00:44 -05:00
tls support self-signed cert 2022-01-07 09:00:44 -05:00
go.mod rewrite the ws handling according to command example in websocket lib. Basically adding timeout for receive and send 2022-01-06 15:29:02 -05:00
go.sum has a websocket shell now! 2022-01-05 12:38:52 -05:00
main.go move xterm lib to assets/external 2022-01-07 11:11:37 -05:00
README.md Update README.md 2022-01-07 09:04:10 -05:00

Web Terminal

A (unsafe) technical demo to export a shell to web browser. It is just a simple demo in case some people are interested in how to setup xterm.js with websocket.

This program is written in the go programming language, using the Gin web framework, gorilla/websocket, pty, and xterm.js! The workflow is simple, the client will initiate a terminal window (xterm.js) and create a websocket with the server. On the server side, it serves the basic HTML/JS/CSS files and websockets (by shovling the data between pty and xterm).

It is amazing what you can do with 270 lines of go code.

To use the program, download/clone the code, and in the web_terminal directory, run go build ., this will create the binary called web_terminal. Then, go to the tls directory and create a self-signed certificate according to the instructions in README.

To run it, use ./web_terminal cmd options_to_cmd. If no cmd and options are given, web_terminal will run bash by default. You can run shells but also single programs, such as htop. For example, you can export the ssh shell, such as ./web_terminal ssh 192.168.1.2 -l pi.

The program has been tested on Linux, WSL2, Raspberry Pi 3B (Debian), and MacOSX.

known bug

On MacOS X, running zsh with web_terminal will produce an extra % each time in Google Chrome. Consider it a feautre, will not fix unless there is a pull request. Safari works fine though.

NOTE

Do NOT run this in an untrusted network. You will expose your shell to anyone that can access your network and Do NOT leave the server running.

Here is a screencast for sshing into Raspberry Pi running pi-hole (./web_terminal ssh 192.168.1.2 -l pi, web_terminal runs in a WSL2 VM on Windows):