Saturday, August 19, 2017

Bash: Using websocketd as web-terminal

Recently, I have got a work that requires a control over remote machine along with few challenges like that machine can be accessed via Remote Desktop via VPN that goes via corporate Firewall. Now that made it very slow because each incoming or outgoing message packet have to cover the circumference of Earth to reach my system.

So I tried lot many tools out there that could solve my problem. I want to eradicate the use of Remote Desktop to expedite the communication.

Since the remote system is a Windows machine, so I tried using SSH via freesshd and found it pretty good. But I want something that could run over browser as web-app.

Finally I found this great tool that is available for converting any command-line program into web-application using WebSocket.

The tool is websocketd, a WebSocket daemon that takes care of handling the WebSocket connections, launching your programs to handle the WebSockets, and passing messages between programs and web-browser.

There are lot many use cases of this tool but I like to use it as a web-terminal.

So, first get the binary file from websocketd under download section. Then, place somewhere from where you can access it easily or make it globally accessible by adding it's location in environment variable path.

After that you can run this command,

$ ./websocketd --port=8080 --devconsole bash

Then open http://localhost:8080/ in the web browser. If you want to access it from any other machine the just replace the localhost with that system IP address.

Use the system commands in the devconsole to execute any command on that system.

No comments:

Post a Comment