This is a simple xterm server implementation that can be used to run xterm remotely in a browser. To connect to the server use the xterm.js library or any other reasonable websocket client.
Run the following commands to setup the server:
git clone
cd xterm-server
docker compose up
You can set the port that the server listens on by setting the XTERM_PORT
environment variable. The default port is 8080
.
docker compose up -e XTERM_PORT=3000
You can connect to the server using the xterm.js library. Here is an example of how you can do this within a browser:
import { Terminal } from "xterm";
const ws = new WebSocket("ws://localhost:3000");
const term = new Terminal();
term.open(document.getElementById("terminal"));
term.onData((data) => {
ws.send(data);
});
ws.onmessage = (event) => {
term.write(event.data);
};
For more minimal usage, you can use tools such as websockat
or wscat
:
websockat ws://localhost:8080