Giter Club home page Giter Club logo

web-terminal's Introduction

Web-Terminal

Web-Terminal is a very lightweight terminal server that provides remote CLI via standard web browser and HTTP protocol. It works on all operating systems supported by Node.js, it doesn't depend on native modules. Fast and easy to install. Supports mutiple sessions.

NOTE: It is not a TTY emulator. It doesn't support complex TTY interaction like in vi, nano and etc. It's good only for simple command/response cases. For fully featured TTY emulator I would suggest Wetty project.

Prerequisites

Node.js v0.10 or newer.

Installation

Install from npm:

$ npm install web-terminal -g

Usage Examples

Starting web-terminal:

$ web-terminal --port 8088

Open your favorite web browser, navigate to http://localhost:8088 and start playing with the browser based CLI.

Integrating web-terminal with web applications:

    var http        = require("http"),
        terminal    = require("web-terminal");

    var app = http.createServer(function (req, res) {
        res.writeHead(200, {"Content-Type": "text/plain"});
        res.end("Hello World\n");
    });
    
    app.listen(1337);
    console.log("Server running at http://127.0.0.1:1337/");
    
    terminal(app);
    console.log("Web-terminal accessible at http://127.0.0.1:1337/terminal");
    

Start the above application, then open your favorite browser and navigate to: http://localhost:8088/terminal

Features

Colors

Most of the display VT100 escape sequences are translated to HTML. However, Web-terminal doesn't present itself as TTY and therefore most programs won't output escape sequences to stdout unless they are explicitly instructed so.

Example configurations:

$ git config --global color.ui always

$ npm config set color always --global

Shell commands

To execute commands through a shell such as bash or cmd.exe (for windows), an environment variable have to be set:

$ export WEB_SHELL=bash

JavaScript REPL

To start the REPL, just type node without arguments in the browser. Type .exit to return to the command prompt. NOTE: REPL is executed on the server, not in the brwoser.

Issues

Commands that require interaction with TTY cause web-terminal to stop responding.

For instance, commands like sudo that require password from TTY directly cause web-terminal to stop responding. In this case the whole process has to be restarted.

The workaround for the time being is to issue sudo with -S argument to instruct sudo to ask for password on the standard IO. Example:

$ sudo -S apt-get install git-core

For Git, passwords have to be stored to avoid this problem:

$ git config credential.helper store

Security Considerations

Web-terminal does not provide embedded authentication and encryption mechanisms. Therefore, if the service is exposed to the Internet, it is strongly recommended to require TLS with client certificates or VPN connection.

License

(MIT License)

Copyright (c) 2013 Boyan Rabchev [email protected]. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

web-terminal's People

Contributors

akfish avatar dcbartlett avatar rabchev avatar rjcorwin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-terminal's Issues

stderr and stdout don't interleave well

Example: type this in the shell and in web-terminal

echo 1; echo 2 >&2; echo 3

Output should be 1 2 3 but on web-terminal it's 1 3 2. I suspect this is due to buffering and I wonder if this is even fixable on NodeJS.

Args Issues

when i try cd out of directory i get
/usr/local/lib/node_modules/web-terminal/lib/terminal.js:293
if (arg[0] === "~") {
^

TypeError: Cannot read property '0' of undefined
at Socket. (/usr/local/lib/node_modules/web-terminal/lib/terminal.js:293:28)
at Socket.emit (node:events:394:28)
at Socket.emit (node:domain:470:12)
at Socket.emitUntyped (/usr/local/lib/node_modules/web-terminal/node_modules/socket.io/dist/typed-events.js:69:22)
at /usr/local/lib/node_modules/web-terminal/node_modules/socket.io/dist/socket.js:428:39
at processTicksAndRejections (node:internal/process/task_queues:78:11)

Socket.io 404

Hey,

Is the expectation that socket.io files need to be gathered after setup? They seem to be missing from the web folder.

Thanks for any help on this!

No such file or directory

I'm trying to use the command web-terminal --port 8088 and I keep getting the error No such file or directory. I installed both globally and locally and it refuses to work.

Commands that require interaction with TTY cause web-terminal to stop responding.

For instance, commands like sudo that require password from TTY directly cause web-terminal to stop responding. In this case the whole process has to be restarted.

The workaround for the time being is to issue sudo with -S argument to instruct sudo to ask for password on the standard IO. Example: "sudo -S npm install"

For Git, passwords have to be stored to avoid this problem; "git config credential.helper store"

Applications

Hi, I want to add more packages? Is it possible? Like tmux, wget, and other basic command line packages?

Backspace key issue

hitting the backspace key brings the browser back to the previous page. Should it capture that key too and ignores it?

Web Terminal on https

I have web terminal running on my server on 4200 port so I can access it like http://ip-address:4200, I want to run it on https like https://ip_address:4200. How can I give ssl certificate information while starting it.

And also I have domain abc.com pointing to my server. So I need terminal to be running with domain name too like http://domain-name:4200

Accessing the bash shell commands

How to configure the host name and all to access and execute bash shell commands.

My questing is instead of putty application, how can I make use of this tool.

Running vim.

Could you provide an example of how to set this up so the /bin/login command is the first thing you see for logging in, and so that when running vim with syntax highlighting we don't see escape codes everywhere?

Thanks!

Color Escape doesn't work

One of my commands outputs a [39;49;00m to reset everything, but doesn't get read correctly in web-terminal.

Output in identifyable elements

I'm trying to use this project to make integration tests for one of my projects. However it would make it a lot easier if I could use jquery to get things like the "last command" and "last output" which could be obtained by wrapping them in spans or divs.

This can somewhat be emulated by jquery now:

Last Command:

jQuery('#content > [id^=ln]:eq(-2) #lnCnt').text()

Last Output:

$( "#content" )
  .contents()
    .filter(function() {
      return this.nodeType === 3;
    })
      .wrap( "<p></p>" )
      .end()
    .filter( "br" )
    .remove(); // wrap text nodes
text = [];
$('#content > [id^=ln]:eq(-2)').nextAll().slice(0, -1).each(function(i, el) {
    text.push($(el).text());
});
text.join('\n'); // output

Why i couldn't start web-terminal?

Hello,
So after installing web-terminal based on the tutorials on homepage here:
https://www.terminal.com/webterminal
I started setting the different port 1991 and tried to access the IP-of-my-server:1991 but seems like it didn't work.
Even though i set it to 8282 port and gave it a try, it still don't work. I still couldn't access the web-terminal.

But then, i decided to create an absolutely new instance and tested again. This time, i was just accessing IP:8282 without setting port or anything and it worked.
Can you tell me what happend please?

Get 'command not found' error for some command (like npm)

Environment

  • Windows 7 x64
  • Node v0.10.21

Steps

  1. Run web-terminal in cmd.exe
  2. Open localhost:8088/terminal/ in browser
  3. Run commands in web terminal, some of them return error message [command name]: command not found.

Commands that run perfectly in a native terminal but won't work with web terminal:

  • npm
  • coffee
  • gulp

One thing they have in common is that they are all commands of globally installed node modules.

"echo" command is false

in terminal.js
line 184:
proc = spawn(env.WEB_SHELL || shell, opts);

should del the second params--null

On Startup error: io.listen is not a function

web-terminal --port 8088
Web-Terminal running at http://localhost:8088/terminal
/usr/local/lib/node_modules/web-terminal/lib/terminal.js:155
io = io.listen(server, { log: false });
^

TypeError: io.listen is not a function
at initialize (/usr/local/lib/node_modules/web-terminal/lib/terminal.js:155:13)
at Object. (/usr/local/lib/node_modules/web-terminal/bin/run.js:28:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

what about start web-terminal and get error like below?

/usr/lib/node_modules/web-terminal/node_modules/commander/lib/command.js:921
  async parseAsync(argv, parseOptions) {
        ^^^^^^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/lib/node_modules/web-terminal/node_modules/commander/index.js:2:21)```

Telnet support ?

Is there any telnet support for this tool ? I am able to use ping command. But I am unable to use telnet command. Does it any internal support that you need to add ? Or we can nail down this issue ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.