Code Monkey home page Code Monkey logo

webssh2's Introduction

WebSSH2

Build Status GitHub version docker build images

Buy Me A Coffee

Web SSH Client using ssh2, socket.io, xterm.js, and express

A bare bones example of an HTML5 web-based terminal emulator and SSH client. We use SSH2 as a client on a host to proxy a Websocket / Socket.io connection to a SSH2 server.

WebSSH2 v0.2.0 demo

Requirements

Node v14.x or above. If using <v14.x you should be able to run by replacing the "read-config" package to @1 like this (after a clone):

npm install --save read-config@1

Just keep in mind that there is no intention to ensure compatability with Node < v14

Instructions

The instructions previously showed cloning directly from main, while normally safe may include "work in progress". It's recommended that after you clone, you switch to a particular tag.

To install:

  1. Clone to a location somewhere

  2. Checkout to the current tag using git checkout current or choose a particular release tag

  3. cd app and npm install --production. If you want to develop and rebuild javascript and other files utilize npm install instead.

  4. If desired, edit app/config.json to change the listener to your liking. There are also some default options which may be definied for a few of the variables.

  5. Run npm start

  6. Fire up a browser, navigate to IP/port of your choice and specify a host (https isn't used here because it's assumed it will be off-loaded to some sort of proxy):

http://localhost:2222/ssh/host/127.0.0.1

You will be prompted for credentials to use on the SSH server via HTTP Basic authentcaiton. This is to permit usage with some SSO systems that can replay credentials over HTTP basic.

Alternatively in main for testing, you can send credentials via POST with the variables "username" and "userpassword".

Customizing client files

See BUILDING.md for more details.

Docker

NOTICE

Docker versions differ from what is in main and are release dependant.

Meaning billchurch/webssh2:latest is the latest official release. This does NOT sync with what is in main on this repo. main is development and will change until it gets a release tag.

On occasion, examples or instructions on main will drift from what is released. You should refer to the tag of the version you're using to ensure you are following the proper guidance.

That being said the most current release version is 0.4.6, see that tag for details.

Instructions

Some configuration options are available as Environment Variables. If there is a configuration option you require which does not have an environment variable please open an issue requesting.

webssh2 images are available in docker hub.

the latest tag will pull the most recent stable release, otherwise you can pull individual tags/releases/versions of this repo by using a particular version in the tag.

For instance:

docker pull billchurch/webssh2:0.4.6

or

docker pull billchurch/webssh2:0.4.7-alpha.2

or

docker pull billchurch/webssh2

for the most recent

If you want to play around localy:

Copy app/config.json.template to app/config.json and modify the latter:

{
  // ...
  "listen": {
    "ip": "0.0.0.0",
    "port": 2222
  }
  // ...
}

Rebuild and run

docker build -t webssh2 .
docker run --name webssh2 -d -p 2222:2222 webssh2

Alternatively if you don't want to rebuild, mount the config at runtime:

docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/config.json webssh2

Alternatively if you don't want to build either and mount the config at runtime relying on the community image :

docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/config.json billchurch/webssh2

Options

Environment Variables

Environment variables introduced in 0.4.7 will override anything specified in config.json. This is useful for settings that may be per-node, or in a container environment. These are optional and will default to whatever their peer config.json settings are

  • LISTEN - string - IP address node should listen on for client connections, defaults to 127.0.0.1. Peer is listen.ip
  • PORT - integer - Port node should listen on for client connections, defaults to 2222. Peer is listen.port
  • SOCKETIO_ORIGINS - array - COORS origins to allow connections from to socket.io server, defaults to localhost:2222. Changed in 0.3.1, to enable previous, less secure, default behavior of everything use *:* (not recommended). Check #240. Peer is socketio.origins
  • SOCKETIO_PATH string - Path to socket.io client files. Default: /ssh/socket.io. Peer is socketio.path
  • SOCKETIO_SERVECLIENT boolean - serve the socket.io client. This is built into the custom javascript, so you shouldn't need this. Kept as an option just in case. Default: false. Peer is socketio.serveClient

POST request vars (in main branch for testing)

  • username - string - username to log into ssh with

  • userpassword string password to log into ssh with

  • port= - integer - port of SSH server (defaults to 22)

  • header= - string - optional header to display on page

  • headerBackground= - string - optional background color of header to display on page

  • sshterm= - string - optional specify terminal emulation to use, defaults to ssh.term in config.json or vt100 if that is null

  • readyTimeout= - integer - How long (in milliseconds) to wait for the SSH handshake to complete. Default: 20000. Enforced Values: Min: 1, Max: 300000

  • cursorBlink - boolean - Cursor blinks (true), does not (false) Default: true.

  • scrollback - integer - Lines in the scrollback buffer. Default: 10000. Enforced Values: Min: 1, Max: 200000

  • tabStopWidth - integer - Tab stops at n characters Default: 8. Enforced Values: Min: 1, Max: 100

  • bellStyle - string - Style of terminal bell: ("sound"|"none"). Default: "sound". Enforced Values: "sound", "none"

  • fontSize - number - Size of terminal font. Default: 12

  • fontFamily - string - Font family

  • letterSpacing - number - Letter spacing

  • lineHeight - number - Line height

GET request vars

  • port= - integer - port of SSH server (defaults to 22)

  • header= - string - optional header to display on page

  • headerBackground= - string - optional background color of header to display on page

  • sshterm= - string - optional specify terminal emulation to use, defaults to ssh.term in config.json or vt100 if that is null

  • readyTimeout= - integer - How long (in milliseconds) to wait for the SSH handshake to complete. Default: 20000. Enforced Values: Min: 1, Max: 300000

  • cursorBlink - boolean - Cursor blinks (true), does not (false) Default: true.

  • scrollback - integer - Lines in the scrollback buffer. Default: 10000. Enforced Values: Min: 1, Max: 200000

  • tabStopWidth - integer - Tab stops at n characters Default: 8. Enforced Values: Min: 1, Max: 100

  • bellStyle - string - Style of terminal bell: ("sound"|"none"). Default: "sound". Enforced Values: "sound", "none"

  • fontSize - number - Size of terminal font. Default: "12"

  • fontFamily - string - Font family

  • letterSpacing - number - Letter spacing

  • lineHeight - integer - Line height

Headers

  • allowreplay - boolean - Allow use of password replay feature, example allowreplay: true

  • mrhsession - string - Can be used to pass APM session for event correlation mrhsession: abc123

Config File Options

config.json contains several options which may be specified to customize to your needs, vs editing the javascript directly. This is JSON format so mind your spacing, brackets, etc...

  • listen.ip - string - IP address node should listen on for client connections, defaults to 127.0.0.1

  • listen.port - integer - Port node should listen on for client connections, defaults to 2222

  • socketio.serveClient - boolean - serve the socket.io client. This is built into the custom javascript, so you shouldn't need this. Kept as an option just in case. Default: false

  • socketio.path - string - Path to socket.io client files. Default: /ssh/socket.io

  • socketio.origins - array - COORS origins to allow connections from to socket.io server, defaults to localhost:2222. Changed in 0.3.1, to enable previous, less secure, default behavior of everything use *:* (not recommended). Check #240

  • user.name - string - Specify user name to authenticate with. In normal cases this should be left to the default null setting.

  • user.password - string - Specify password to authenticate with. In normal cases this should be left to the default null setting.

  • user.overridebasic - boolean - When set to true ignores Authorization: Basic header sent from client and use credentials defined in user.name and user.password instead. Defaults to false. issue 242 for more information.

  • ssh.host - string - Specify host to connect to. May be either hostname or IP address. Defaults to null.

  • ssh.port - integer - Specify SSH port to connect to, defaults to 22

  • ssh.term - string - Specify terminal emulation to use, defaults to vt100 if null

  • ssh.readyTimeout - integer - How long (in milliseconds) to wait for the SSH handshake to complete. Default: 20000.

  • ssh.keepaliveInterval - integer - How often (in milliseconds) to send SSH-level keepalive packets to the server (in a similar way as OpenSSH's ServerAliveInterval config option). Set to 0 to disable. Default: 120000.

  • ssh.keepaliveCountMax - integer - How many consecutive, unanswered SSH-level keepalive packets that can be sent to the server before disconnection (similar to OpenSSH's ServerAliveCountMax config option). Default: 10.

  • allowedSubnets - array - A list of subnets that the server is allowed to connect to via SSH. An empty array means all subnets are permitted; no restriction. Default: empty array.

  • terminal.cursorBlink - boolean - Cursor blinks (true), does not (false) Default: true.

  • terminal.scrollback - integer - Lines in the scrollback buffer. Default: 10000.

  • terminal.tabStopWidth - integer - Tab stops at n characters Default: 8.

  • terminal.bellStyle - string - Style of terminal bell: (sound|none). Default: "sound".

  • terminal.fontSize - number - Size of terminal font. Default: 14.

  • terminal.fontFamily - string - Font family

  • terminal.letterSpacing - number - Letter spacing

  • terminal.lineHeight - number - Line height

  • header.text - string - Specify header text, defaults to My Header but may also be set to null. When set to null no header bar will be displayed on the client.

  • header.background - string - Header background, defaults to green.

  • session.name - string - Name of session ID cookie. it's not a horrible idea to make this something unique.

  • session.secret - string - Secret key for cookie encryption. You should change this in production.

  • options.challengeButton - boolean - Challenge button. This option, which is still under development, allows the user to resend the password to the server (in cases of step-up authentication for things like sudo or a router enable command.

  • options.allowreauth - boolean - Reauth button. This option creates an option to provide a button to create a new session with new credentials. See issue 51 and pull 85 for more detail.

  • algorithms - object - This option allows you to explicitly override the default transport layer algorithms used for the connection. Each value must be an array of valid algorithms for that category. The order of the algorithms in the arrays are important, with the most favorable being first. Valid keys:

    • kex - array - Key exchange algorithms.

      • Default values:

        1. ecdh-sha2-nistp256 (node v0.11.14 or newer)
        2. ecdh-sha2-nistp384 (node v0.11.14 or newer)
        3. ecdh-sha2-nistp521 (node v0.11.14 or newer)
        4. diffie-hellman-group-exchange-sha256 (node v0.11.12 or newer)
        5. diffie-hellman-group14-sha1
      • Supported values:

        • ecdh-sha2-nistp256 (node v0.11.14 or newer)
        • ecdh-sha2-nistp384 (node v0.11.14 or newer)
        • ecdh-sha2-nistp521 (node v0.11.14 or newer)
        • diffie-hellman-group-exchange-sha256 (node v0.11.12 or newer)
        • diffie-hellman-group14-sha1
        • diffie-hellman-group-exchange-sha1 (node v0.11.12 or newer)
        • diffie-hellman-group1-sha1
    • cipher - array - Ciphers.

      • Default values:

        1. aes128-ctr
        2. aes192-ctr
        3. aes256-ctr
        4. aes128-gcm (node v0.11.12 or newer)
        5. [email protected] (node v0.11.12 or newer)
        6. aes256-gcm (node v0.11.12 or newer)
        7. [email protected] (node v0.11.12 or newer)
      • Supported values:

        • aes128-ctr
        • aes192-ctr
        • aes256-ctr
        • aes128-gcm (node v0.11.12 or newer)
        • [email protected] (node v0.11.12 or newer)
        • aes256-gcm (node v0.11.12 or newer)
        • [email protected] (node v0.11.12 or newer)
        • aes256-cbc
        • aes192-cbc
        • aes128-cbc
        • blowfish-cbc
        • 3des-cbc
        • arcfour256
        • arcfour128
        • cast128-cbc
        • arcfour
    • hmac - array - (H)MAC algorithms.

      • Default values:

        1. hmac-sha2-256
        2. hmac-sha2-512
        3. hmac-sha1
      • Supported values:

        • hmac-sha2-256
        • hmac-sha2-512
        • hmac-sha1
        • hmac-md5
        • hmac-sha2-256-96
        • hmac-sha2-512-96
        • hmac-ripemd160
        • hmac-sha1-96
        • hmac-md5-96
    • compress - array - Compression algorithms.

  • serverlog.client - boolean - Enables client command logging on server log (console.log). Very simple at this point, buffers data from client until it receives a line-feed then dumps buffer to console.log with session information for tracking. Will capture anything send from client, including passwords, so use for testing only... Default: false. Example:

    • serverlog.client: GcZDThwA4UahDiKO2gkMYd7YPIfVAEFW/mnf0NUugLMFRHhsWAAAA host: 192.168.99.80 command: ls -lat
  • serverlog.server - boolean - not implemented, default: false.

  • accesslog - boolean - http style access logging to console.log, default: false

  • safeShutdownDuration - integer - maximum delay, in seconds, given to users before the server stops when doing a safe shutdown

Client-side logging

Clicking Start logging on the status bar will log all data to the client. A Download log option will appear after starting the logging. You may download at any time to the client. You may stop logging at any time my pressing the Logging - STOP LOG. Note that clicking the Start logging option again will cause the current log to be overwritten, so be sure to download first.

Example:

http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&headerBackground=red

CONTRIBUTING

As of 0.4.0, we're trying our best to conform to the Airbnb Javascript Style Guide. I'm hoping this will make contributions easier and keep the code readable. I love shortcuts more than anyone but I've found when making changes to code I've not looked at in a while, it can take me a few momements to deconstruct what was being done due to readbility issues. While I don't agree with every decision in the style guide (semi-colons, yuk), it is a good base to keep the code consistent.

If you've not used it before, I recommend installing the vscode extensions for that and Prettier and getting familiar. The autocorrections are great (especially if you hate dealing with semi-colons...)

All contributions are welcome, all may not make it into a release... To increase the chances of your contribution making it into a release, try your best to conform to the style guides and targets of the project.

Tips

  • You can enable extended debug messages in the browser Java console using:
    • localStorage.debug = '*'; - Debug Everything (a lot of messages)
    • localStorage.debug = 'WebSSH2'; - Debug potentially interesting WebSSH2 related messages (replaying credentials, resizing data, other control messages)
  • If you want to add custom JavaScript to the browser client you can either modify ./src/client.html and add a <script> element, modify ./src/index.js directly, or check out webpack.*.js and add your custom javascript file to a task there (best option).

webssh2's People

Contributors

bara666 avatar billchurch avatar cchemin avatar dependabot[bot] avatar edgarogh avatar github-actions[bot] avatar greenkeeper[bot] avatar ilteoood avatar jaredh159 avatar perlun avatar unclesamswiss avatar utopiah avatar wuchihsu avatar zhangchao-wooc 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  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

webssh2's Issues

An in-range update of uglifyjs-webpack-plugin is breaking the build 🚨

Version 1.2.6 of uglifyjs-webpack-plugin was just published.

Branch Build failing 🚨
Dependency [uglifyjs-webpack-plugin](https://github.com/webpack-contrib/uglifyjs-webpack-plugin)
Current Version 1.2.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

uglifyjs-webpack-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v1.2.6

1.2.6 (2018-06-20)

Bug Fixes

  • disable inline optimization by default (#308) (6ab0918)
  • don't use a worker farm unless more than one process is required (#280) (3f0767b)
  • better handle invalid source map (#284) (dbebb3b)
  • perf regression with memory usage for source maps (#305) (3ca5eaf)
  • return missing important information for uglify warnings (#306) (4f50156)
Commits

The new version differs by 7 commits.

  • 1521c82 chore(release): 1.2.6
  • 120e4b0 docs: fix broken markdown (#315)
  • 4f50156 fix: return missing important information (#306)
  • 6ab0918 fix: disable inline optimization by default (#308)
  • 3ca5eaf fix: perf regression (#305)
  • 3f0767b fix: don't use a worker farm unless more than one process is required (#280)
  • dbebb3b fix: improve isSouceMap check (#284)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

WebSSH2/index.js:56:93 TypeError: Cannot set property 'port' of undefined

http://localhost:2222/ssh/host/192.168.10.243?port=22&header=My%20Header&color=red

TypeError: Cannot set property 'port' of undefined
at /Users/xxx/safe/node/WebSSH2/index.js:56:93
at Layer.handle [as handle_request] (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/layer.js:95:5)
at /Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/index.js:277:22
at param (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/index.js:349:14)
at param (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/index.js:365:14)
at Function.process_params (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/index.js:410:3)
at next (/Users/xxx/safe/node/WebSSH2/node_modules/express/lib/router/index.js:271:10)

could u help me with this weird problem?

sometimes the window shows correctly,
but sometimes after I type some code and type the Enter,
something happens very weird, what i type was disappear and window always shows just one line,
the scene likes the picture below.

Uploading image.png…

I am a Chinese, maybe what I express is not clear enough to understand, Could u tell me some hints that I can modify.Very appreciate!

https

Hi,

Really a great tool. Anyway is there a change to make it with https?

BR.

Fill and send command from JS

I figured out that can run term.write('php test.php'); to inject text onto the command prompt but how can I then send it? term.send() doesn't appear to do what I need and appears to be something internal.

Is there an easy way to submit this (looked into keyboard events but that seems messy, nothing methods available and I'm unsure what's available in websockets in this repo in order to submit a command).

Any tips on how to trigger a command from browser hugely appreciated!

An in-range update of snyk is breaking the build 🚨

Version 1.81.0 of snyk was just published.

Branch Build failing 🚨
Dependency snyk
Current Version 1.80.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

snyk is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • bitHound - Dependencies No failing dependencies. Details
  • bitHound - Code No failing files. Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 1 commits.

  • 8db3a39 feat: bump nuget plugin to 1.6.1

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @fortawesome/fontawesome is breaking the build 🚨

Version 1.1.6 of @fortawesome/fontawesome was just published.

Branch Build failing 🚨
Dependency @fortawesome/fontawesome
Current Version 1.1.5
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@fortawesome/fontawesome is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • bitHound - Code No failing files. Details
  • bitHound - Dependencies No failing dependencies. Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

how config or set the charset

[root@appserver ~]# df -h
Îļþϵͳ ÈÝÁ¿ ÒÑÓà ¿ÉÓà ÒÑÓÃ%% ¹ÒÔصã
/dev/mapper/VolGroup-lv_root
507G 153G 328G 32% /
tmpfs 16G 1.2M 16G 1% /dev/shm
/dev/xvda1 485M 52M 408M 12% /boot
192.168.10.123:/MyWork
985G 223G 712G 24% /MyWork

the “¹ÒÔص㔠cannot display,is china word

Seperate servers for Node server side and client side

I need to have something akin to client-full.htm (will be client-full.php) running on Apache on one server and the terminal talking to Node running app.js on another server.

It almost works, but has an issue with webssh2.js line - 10167 and complains that:
https://samedomain.com/socket.io/?EIO=3&transport=polling&t=M0nVb6d 404 (Not Found)

On a working setup, the URL for websockets seems to be:
ws://samedomain.com:3000/socket.io/?EIO=3&transport=websocket&sid=vFiFVZbmgiwsRg0SAAAI

Is it possible to easily override the protocol and domain it'll contact for all websocket related things? So it always looks to another server for the socket?

ie, I want to specify ws://anotherdomain.com as the protocol and domain it'll look to for websockets.

An in-range update of @fortawesome/fontawesome-free-solid is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 5.0.10 of @fortawesome/fontawesome-free-solid was just published.

Branch Build failing 🚨
Dependency @fortawesome/fontawesome-free-solid
Current Version 5.0.9
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

@fortawesome/fontawesome-free-solid is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • bitHound - Code No failing files. Details
  • bitHound - Dependencies No failing dependencies. Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Release 5.0.10

Added

Changed

  • Updating depth of dna icon
  • Updating pied-piper, adding pied-piper-hat

Fixed

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

how control input cmd

how control input cmd?
1、record
all input、and all output to database
2、control
filter unsafe input and unsafe output
3、interface
where is the interface api,how use api to monitor and control

thank you

Regarding integration of WebSSH2 in to my project

When opening an issue, please include the follwing information:
Node Version : v8.9.4
Server OS Version
WebSSH2 release version : 0.2.3
OS and Version of SSH server connecting to
Browser Version and OS : Firefox 58.0.2 (64-bit)

Hi, is it possible to use WebSSH2 directly in to one of my project ? Front end is angular js and node js packaging is used to connect to remote host. My requirement is to create a new page with a terminal embedded in it and I should be able to ssh to host with specific port.

I installed WebSSH2 in my Ubuntu 16.04. From browser, while typing "http://localhost:2222/ssh/host/host_name", I am able to reach to ssh port. So is it possible to embed in a web page rather than invoking separately.

Thanks in advance, Jay.

Error messages not displayed properly on status bar

Depending on how the connection closes, some error messages may not be displayed on the status bar.

An example is if the user enters an invalid username or password, they would just receive SSH CONNECTION CLOSED.

Keeping session

node-v8.11.3-linux-x64
Ubuntu 18.04 amd64
[email protected]
OpenSSH_7.6p1 Ubuntu-4, OpenSSL 1.0.2n 7 Dec 2017
Firefox for Ubuntu 60.0.2 (64-bit)

This is a question first (should I have asked that elsewhere?), not yet an issue. I was wondering whether there is some way to make sessions in WebSSH2 persistent over a loss of internet connection. Hope that is clear.
Thanks!

How to build production

I want to use this in produtcion envirment, but it contains source file and any other file that no need to run. So, can you please tell me how to build production in envirment, just like Java Web build to .war or Java source build to .jar? Thanks

Login banners from some *nix systems do not display properly

Login banners from some *nix systems do not display properly

When a *nix system or router is configured with an sshd-banner (typically /etc/ssh/sshd-banner) and the file is saved with lf vs cr/lf, it will display improperly on the web terminal (xterm.js).

I'm not sure if this is a "problem" with xterm.js or something else. Need to investigate further.

messages image 610987682

reconnection when server websocket available again

If the Node webserver is stopped, it'll cause the terminal to stop working, which is understandable. If I start the Node webserver again, it won't allow the terminal to continue working.

I've found the socket.io.reconnection(false) line, which if I remove, does then allow reconnection and the terminal to work, but then the terminal outputs extra line breaks after each line.

Is there anyway to get reconnections to work and allow the terminal to keep functioning as it was, without the extra line breaks?

npm start is not working

Hi billchurch,
As you suggested I used your repository. Here are the steps I did:-

  1. git clone https://github.com/billchurch/WebSSH2
  2. npm install --production
  3. npm start.

When I executed npm start it throws me following error:-

root@ubuntu:/home/ubuntu/WebSSH2# npm start

[email protected] start /home/ubuntu/WebSSH2
node index.js

WebSSH2 service reading config from: /home/ubuntu/WebSSH2/config.json
/home/ubuntu/WebSSH2/node_modules/read-config/lib/load/merge-configs.js:7
return merge({}, ...configs, (a, b) => {
^^^

SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/ubuntu/WebSSH2/node_modules/read-config/lib/load/merge-parents.js:3:22)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)

npm ERR! Linux 4.4.0-109-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webssh2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webssh2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webssh2
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/WebSSH2/root@ubuntu:/home/ubuntu/WebSSH2# npm start

[email protected] start /home/ubuntu/WebSSH2
node index.js

WebSSH2 service reading config from: /home/ubuntu/WebSSH2/config.json
/home/ubuntu/WebSSH2/node_modules/read-config/lib/load/merge-configs.js:7
return merge({}, ...configs, (a, b) => {
^^^

SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/ubuntu/WebSSH2/node_modules/read-config/lib/load/merge-parents.js:3:22)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)

npm ERR! Linux 4.4.0-109-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webssh2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webssh2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webssh2
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/WebSSH2/npm-debug.log

Content from npm-debug.log:-
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 silly lifecycle [email protected]
prestart: no script for prestart, continuing
7 info lifecycle [email protected]start: [email protected]
8 verbose lifecycle [email protected]
start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]start: PATH: /usr/share/npm/bin/node-gyp-bin:/home/ubuntu/WebSSH2/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
10 verbose lifecycle [email protected]
start: CWD: /home/ubuntu/WebSSH2
11 silly lifecycle [email protected]start: Args: [ '-c', 'node index.js' ]
12 silly lifecycle [email protected]
start: Returned: code: 1 signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: node index.js
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at EventEmitter.emit (events.js:172:7)
14 verbose stack at ChildProcess. (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack at emitTwo (events.js:87:13)
14 verbose stack at ChildProcess.emit (events.js:172:7)
14 verbose stack at maybeClose (internal/child_process.js:821:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid [email protected]
16 verbose cwd /home/ubuntu/WebSSH2
17 error Linux 4.4.0-109-generic
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
19 error node v4.2.6
20 error npm v3.5.2
21 error code ELIFECYCLE
22 error [email protected] start: node index.js
22 error Exit status 1
23 error Failed at the [email protected] start script 'node index.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the webssh2 package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node index.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs webssh2
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls webssh2
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Any Idea? Why it is failing npm start

Powerline Supports

Is it able to add powerline supports of this WebSSH client? I tried to add @font-face in the public/WebSSH2.css in the .terminal block, but then my SSH client become only one line.

I used Ubuntu Mono derivative Powerline.ttf from powerline/fonts.

Emulator not working in my browser

Hi, I tried installing your project to run into browser. However, every time I am getting error below:

WEBSOCKET ERROR - Refresh the browser and try again

Please find the screenshot below:
Screenshot

SSH CONNECTION CLOSE - Error: Handshake failed: no matching client

client os

mac 10.12.3
uname -a
Darwin QQ1160.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

1.safari ver 10.0.3 (12602.4.8)

http://localhost:2222/ssh/host/192.168.10.243

2.server: name -a

Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux

3.error

kali linux out error
SSH CONNECTION CLOSE - Error: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESET CREDENTIALS

in chrome 56.0.2924.87 (64-bit)
SSH CONNECTION CLOSE - Error: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipher CREDENTIALS

node index.js

console

webssh2 Login: user=root from=127.0.0.1 host=192.168.10.243 port=22 sessionID=undefined allowreplay=undefined
Headers: {"host":"localhost:2222","connection":"keep-alive","cache-control":"max-age=0","authorization":"Basic cm9vdDpaMnpvTzAxSXxsNmI5UUdTNSo=","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","dnt":"1","accept-encoding":"gzip, deflate, sdch, br","accept-language":"zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4","cookie":"BEEFSESSION=53d7360526c8a0cc2ae71c1789503db1167fe02928db3fc51bd2668fbcd0bb721f66a20ae887275e81beaf3c661c0e0938ead29ad3a77e1abaecf121c30341cf37b3519a318bd52a8dff5be6f81d5370; _dradis_session=bjl0N29OeTRRRzBVQmZhYzNlSi92ZjBiWGhEaHdXUVNzdFdydWJ1SHU1cEUwSHRqbTh1bThEZkJjNjBhMlZrWWZRSUtzZjNsaDZjRml1RnZyRkhrSG1HNldSM3AyeThUWnZBN1E2RVM3T2E1Z1JDbW1Na1pWakdmUEV4UHhoa3lGRDI5NGp0TUE3MDl1bHRXdm8yc0ZvQk01MFpTbkxJUFFkdnUxeG5Db0x0NUdNM2FGRkJMREc1aFd0KzRXaXd1WGJZZ2gvSEZYei9yY3EwNU5HN2hiNkxFS0ZyenJWQmM5MlZSazZRUWJ5WGw0OGxTOVFKZnd3ZVJQcUwwbUx0NHN2M2h6cjJWTnNzUHFWOHFjQ0g4TEE9PS0tdXAyd2psV0lHNTNZM0t6bnUrZTNUdz09--c77e8fdc45cc737c846c1c3cc25d8cbd5b08b5ad; io=XedVUh8QMvag1pcmAAAH","if-none-match":"W/\"298-15a280f3268\"","if-modified-since":"Fri, 10 Feb 2017 12:46:09 GMT"}
on.error - Error: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipher
webssh2 Login: user=root from=127.0.0.1 host=192.168.10.243 port=22 sessionID=undefined allowreplay=undefined
Headers: {"host":"localhost:2222","cookie":"io=Hhuu5qJYkuv6tFl0AAAC","authorization":"Basic cm9vdDpaMnpvTzAxSXxsNmI5UUdTNSo=","connection":"keep-alive","upgrade-insecure-requests":"1","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8","accept-language":"zh-cn","cache-control":"max-age=0","accept-encoding":"gzip, deflate"}
on.error - Error: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: read ECONNRESETError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipherError: Handshake failed: no matching client->server cipher

#kali linux
uname -a
Linux kali 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-21) x86_64 GNU/Linux

other linux is ok

uname -a
Linux appserver 2.6.32-279.el6.x86_64 #1 SMP Thu Jun 21 15:00:18 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The engines config in 1 of your package.json files was updated to the new Node.js version

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

alternative auth

basic auth in most browsers is really annoying because it saves the auth credentials based on the subdomain. meaning that when i connect to server A with credentials A, all is good... but then when i go to connect to server B it automatically tries to pass credentials A and doesn't prompt me again. Worse yet, if someone clicks cancel on basic auth prompt, it keeps passing NO credentials and webssh2 will just see a connection attempt without session.username/password.

Any ideas on how I could maybe replace basic auth with a forms based overlay perhaps?

Option for per request authentication

Would it be possible to add an option to re-request the authentication each time you do a new request for an SSH session ?

We're using webssh on a jumphost server, but most target devices use different credentials. This means that almost every time we need to flush the browser authentication cache when we want to connect to a device, which is cumbersome.

client (public) into IIS

Hi Bill Church,

Excellent implementation.

Is it possible to split the client (public) part from node.js to some other language? Say dotnet (iis) or java.

I try copy the “public” folder and put it under IIS web site, changed the socket connection to “socket = io.connect('http://localhost:2222/socket.io/')” But this is not working!

Can you please guide how to unplug the client part from node.js and put it in different platform?

Thanks

Waiting for terminal command to finish execute then run another

First of all, amazing project!

I am using it to execute a series of events by simply clicking a button. the code I added is:

<div id="runCommand"><a class="toggleLog" href="javascript:void(0);"
        onclick="runCommand();">Write command</a></div>
		
		<script type="text/javascript">
		function runCommand() {
			var filename = 'bigFile.txt';
                       console.log(term);
			term.send(`copy tftp://my-ip/tmp/${filename} dir:\n`);
                          console.log(term);
			term.send('\n');
			term.send('dir\n');
		}
		</script>

The problem is that dir is not executing, because the command before takes time to copy the file.

Is there any solution or way to check that the terminal is in writeable state? I tried to check for the writable flag of the term object but it is true.

Thanks!

parsing messages from the terminal

Hi,
Is there any event to watch for terminal outputs?

For example: executing "ls" and then parse the output string of all the dirs / files

Can't retry login

on first try, I did give login informations.
now, each time i refresh http://localhost:2222/ssh/host/127.0.0.1, I get :

` npm start

[email protected] start /home/christophe/tmp/WebSSH2
node index
/home/christophe/tmp/WebSSH2/node_modules/ssh2/lib/client.js:209
throw new Error('Invalid username');
^
Error: Invalid username
at Client.connect (/home/christophe/tmp/WebSSH2/node_modules/ssh2/lib/client.js:209:11)
at Namespace. (/home/christophe/tmp/WebSSH2/index.js:105:8)
at emitOne (events.js:96:13)
at Namespace.emit (events.js:188:7)
at Namespace.emit (/home/christophe/tmp/WebSSH2/node_modules/socket.io/lib/namespace.js:209:10)
at /home/christophe/tmp/WebSSH2/node_modules/socket.io/lib/namespace.js:177:14
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node index
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node index'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the WebSSH2 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs WebSSH2
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls WebSSH2
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/christophe/tmp/WebSSH2/npm-debug.log
`

Connect to a server using a private key

Do you think it would be possible to connect to the remote server using a private key either given in the configuration file or the one from the user starting the server instead of giving the username and password every time or in a configuration file?

Actually, I dislike enabling password authentication on my servers...

Have you thought about it already?

Thanks.

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.