diff --git a/.bithoundrc b/.bithoundrc index ce99969..b2a8f88 100644 --- a/.bithoundrc +++ b/.bithoundrc @@ -12,5 +12,8 @@ "read-config", "socket.io" ] - } + }, + "ignore": [ + "public/src/**" + ] } \ No newline at end of file diff --git a/ChangeLog.md b/ChangeLog.md index d14bf08..f7f9bd7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,22 +1,44 @@ # Change Log -## [Unreleased] +## [0.1.0] 2017-05-27 ### Added - This ChangeLog.md file +- Support for UTF-8 characters (thanks @bara666) - Snyk, Bithound, Travis CI - Cross platform improvements (path mappings) - Session fixup between Express and Socket.io +- Session secret settings in config.json - env variable `DEBUG=ssh2` will put the `ssh2` module into debug mode -- env variable `debug=WebSSH2` will output additional debug messages for functions +- env variable `DEBUG=WebSSH2` will output additional debug messages for functions and events in the application (not including the ssh2 module debug) +- using Grunt to pull js and css source files from other modules `npm run build` to rebuild these if changed or updated. +- `useminified` option in `config.json` to enable using minified client side javascript (true) defaults to false (non-minified) +- sshterm= query option to specify TERM environment variable for host, valid strings are alpha-numeric with a hypen (validated). Otherwise the default ssh.term variable from `config.json` will be used. +- validation for host (v4,v6,fqdn,hostname), port (integer 2-65535), and header (sanitized) from URL input ### Changed -- erorr handling in public/client.js +- error handling in public/client.js +- moved socket.io operations to their own file /socket/index.js, more changes like this to come (./socket/index.js) +- all session based variables are now under the req.session.ssh property or socket.request.ssh (./index.js) +- moved SSH algorithms to config.json and defined as a session variable (..session.ssh.algorithms) +-- prep for future feature to define algorithms in header or some other method to enable separate ciphers per host +- minified and combined all js files to a single js in `./public/webssh2.min.js` also included a sourcemap `./public/webssh2.min.js` which maps to `./public/webssh2.js` for easier troubleshooting. +- combined all css files to a single css in `./public/webssh2.css` +- minified all css files to a single css in `./public/webssh2.min.css` +- copied all unmodified source css and js to /public/src/css and /public/src/js respectively (for troubleshooting/etc) +- sourcemaps of all minified code (in /public/src and /public/src/js) +- renamed `client.htm` to `client-full.htm` +- created `client-min.htm` to serve minified javascript +- if header.text is null in config.json and header is not defined as a get parameter the Header will not be displayed. Both of these must be null / undefined and not specified as get parameters. ### Fixed -- Multiple errors may ovewrite status bar which would cause confusion as to what originally caused the error. Example, ssh server disconnects which prompts a cascade of events (conn.on('end'), socket.on('disconnect'), conn.on('close')) and the original reason (conn.on('end')) would be lost and the user would erroneously receive a WEBSOCKET error as the last event to fire would be the websocket connection closing from the app. +- Multiple errors may overwrite status bar which would cause confusion as to what originally caused the error. Example, ssh server disconnects which prompts a cascade of events (conn.on('end'), socket.on('disconnect'), conn.on('close')) and the original reason (conn.on('end')) would be lost and the user would erroneously receive a WEBSOCKET error as the last event to fire would be the websocket connection closing from the app. - ensure ssh session is closed when a browser disconnects from the websocket +- if headerBackground is changed, status background is changed to the same color (typo, fixed) -## [0.0.5] - 2017-0323 +### Removed +- Express Static References directly to module source directories due to concatenating and minifying js/css + +## [0.0.5] - 2017-03-23 ### Added - Added experimental support for logging (see Readme) diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..5c18456 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,73 @@ +module.exports = function (grunt) { + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + copy: { + main: { + files: [ + { + expand: true, + flatten: true, + src: [ + 'node_modules/xterm/dist/xterm.css', + 'src/css/style.css' + ], + dest: 'public/src/css' + }, + { + expand: true, + flatten: true, + src: [ + 'node_modules/xterm/dist/xterm.js', + 'node_modules/xterm/dist/xterm.js.map', + 'node_modules/xterm/dist/addons/fit/fit.js', + 'node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js', + 'node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js.map', + 'src/js/client.js' + ], + dest: 'public/src/js' + } + ] + } + }, + concat: { + options: { + sourceMap: true, + sourceMapName: 'public/src/webssh2.concat.map', + sourceMapStyle: 'embed' + }, + css: { + src: ['public/src/css/*.css'], + dest: 'public/webssh2.css' + }, + js: { + src: [ + 'public/src/js/xterm.js', + 'public/src/js/fit.js', + 'public/src/js/socket.io.js', + 'public/src/js/client.js' + ], + dest: 'public/webssh2.js' + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', + sourceMap: true, + sourceMapName: 'public/src/webssh2.min.map' + }, + build: { + src: ['public/src/js/xterm.js', 'public/src/js/fit.js', 'public/src/js/socket.io.js', 'public/src/js/client.js'], + dest: 'public/webssh2.min.js' + } + } + }) + + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-contrib-copy') + grunt.loadNpmTasks('grunt-contrib-concat') + grunt.loadNpmTasks('grunt-contrib-uglify') + + // Default task(s). + grunt.registerTask('default', ['copy', 'concat', 'uglify']) +} diff --git a/README.md b/README.md index f341ac5..e5c067e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# WebSSH2 [](https://badge.fury.io/gh/BillChurch%2FWebSSH2) [](https://travis-ci.org/billchurch/WebSSH2) [](https://snyk.io/test/github/billchurch/webssh2) [](https://www.bithound.io/github/billchurch/WebSSH2) [](https://www.bithound.io/github/billchurch/WebSSH2/master/dependencies/npm) [](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764) +# WebSSH2 [](https://badge.fury.io/gh/billchurch%2FWebSSH2) [](https://travis-ci.org/billchurch/WebSSH2) [](https://snyk.io/test/github/billchurch/webssh2) [](https://www.bithound.io/github/billchurch/WebSSH2) [](https://www.bithound.io/github/billchurch/WebSSH2/master/dependencies/npm) [](https://nodesecurity.io/orgs/billchurch/projects/b0a0d9df-1340-43ef-9736-ef983c057764) Web SSH Client using ssh2, socket.io, xterm.js, and express Bare bones example of using SSH2 as a client on a host to proxy a Websocket / Socket.io connection to a SSH2 server. @@ -8,7 +8,7 @@ Bare bones example of using SSH2 as a client on a host to proxy a Websocket / So # Instructions To install: -1. Clone to a location somewhere and `npm install` +1. Clone to a location somewhere and `npm install --production`. If you want to develop and rebuild javascript and other files utilize `npm install` instead. 2. If desired, edit 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. @@ -21,52 +21,136 @@ 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. -# Options (GET request vars) +# Options -port= - port of SSH server (defaults to 22) +## GET request vars -header= - optional header to display on page +* **port=** - _integer_ - port of SSH server (defaults to 22) -headerBackground= - optional background color of header to display on page +* **header=** - _string_ - optional header to display on page -# Config File Options -config.json contains several options which may be specified to customize to your needs, vs editing the javascript direclty. This is JSON format so mind your spacing, brackets, etc... +* **headerBackground=** - _string_ - optional background color of header to display on page -`listen.ip` default `127.0.0.1` -* IP address node should listen on for client connections. +## Headers -`listen.port` default `2222` -* Port node should listen on for client connections. +* **allowreplay** - _boolean_ - Allow use of password replay feature, example `allowreplay: true` -`user.name` default `null` -* Specify user name to authenticate with. +## 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... -`user.password` default `null` -* Specify password to authenticate with. +* **listen.ip** - _string_ - IP address node should listen on for client connections, defaults to `127.0.0.1` -`ssh.host` default `null` -* Specify host to connect to. +* **listen.port** - _integer_ - Port node should listen on for client connections, defaults to `2222` -`ssh.port` default `22` -* Specify SSH port to connect to. +* **user.name** - _string_ - Specify user name to authenticate with. In normal cases this should be left to the default `null` setting. -`ssh.term` default `xterm-color` -* Specify terminal emulation to use. +* **user.password** - _string_ - Specify password to authenticate with. In normal cases this should be left to the default `null` setting. -`header.text` -* Specify header text, defaults to `My Header` but may also be set to `null`. +* **ssh.host** - _string_ - Specify host to connect to. May be either hostname or IP address. Defaults to `null`. -`header.background` -* Header background, defaults to `green`. +* **ssh.port** - _integer_ - Specify SSH port to connect to, defaults to `22` -`session.name` -* Name of session ID cookie. it's not a horrible idea to make this something unique. +* **ssh.term** - _string_ - Specify terminal emulation to use, defaults to `xterm-color` -`session.secret` -* Secret key for cookie encryption. You should change this in production. +* **useminified** - _boolean_ - Choose between ./public/client-full.htm (false/non-minified) or ./public/client-min.htm (true/minified js), defaults to false (non-minified version) -`options.challengeButton` -* 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. +* **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. + +* **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 + 2. ecdh-sha2-nistp384 + 3. ecdh-sha2-nistp521 + 4. diffie-hellman-group-exchange-sha256 + 5. diffie-hellman-group14-sha1 + + * Supported values: + + * ecdh-sha2-nistp256 + * ecdh-sha2-nistp384 + * ecdh-sha2-nistp521 + * diffie-hellman-group-exchange-sha256 + * diffie-hellman-group14-sha1 + * diffie-hellman-group-exchange-sha1 + * diffie-hellman-group1-sha1 + + * **cipher** - _array_ - Ciphers. + + * Default values: + + 1. aes128-ctr + 2. aes192-ctr + 3. aes256-ctr + 4. aes128-gcm + 5. aes128-gcm@openssh.com + 6. aes256-gcm + 7. aes256-gcm@openssh.com + 8. aes256-cbc **legacy cipher for backward compatibility, should removed :+1:** + + * Supported values: + + * aes128-ctr + * aes192-ctr + * aes256-ctr + * aes128-gcm + * aes128-gcm@openssh.com + * aes256-gcm + * aes256-gcm@openssh.com + * 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 **legacy hmac for backward compatibility, should removed :+1:** + + * 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. + + * Default values: + + 1. none + 2. zlib@openssh.com + 3. zlib + + * Supported values: + + * none + * zlib@openssh.com + * zlib # Experimental 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. @@ -75,3 +159,7 @@ Clicking `Start logging` on the status bar will log all data to the client. A `D http://localhost:2222/ssh/host/192.168.1.1?port=2244&header=My%20Header&color=red +# Tips +* If you want to add custom JavaScript to the browser client you can either modify `./public/client-(full|min).html` and add a ** - - - + +