npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hssh

v1.2.0

Published

Http(S) Shell that works just like SSH

Downloads

6

Readme

#Http(S) SHell for Node.JS Web Server

Introduction

What it is

hssh is a SSH like shell using WebSocket based on Http(s) to connect remote node.js web server. Features include remote terminal / port forwarding / file transfer etc.

Why

Couple reasons:

  • SSH is not supported by server
  • Only port 80(443) being exposed
  • Need access internal servers like MYSQL / MongoDB through port 80(443)
  • Need transfer file between server and local
  • Need access backend services withing VPN or firewall.
  • etc etc

What it can do

A lot of things:

  • It is a comprehensive shell. You can log onto remote server through your local terminal.
  • Tunnel (port forward)
  • SOCKS5 proxy (TBD)
  • File transfer (TBD)
  • more

How does it work

hssh uses WebSockets as underlying communication channel. Client forwards CLI keypress to Server which further streams it to a bash process. Based on this idea, tunnel works similarly (by forwarding TCP pakcets). See simple diagram below:

hssh-diagram

###Is it secure

WebSocket is using underlying Http(s) protocol. The data transportation will be encrypted with ssl if web server is under https.

For user authentication, see User Authentication section below.

##Quick Start

To use hssh you will need have:

  • Install hssh client
  • Enable node.js webserver with hssh support

###Install hssh Client

Install hssh through npm:

npm install -g hssh

The command will install hssh globally which includes cli command hssh and hssh-serve

hssh is the main cli which connects remote web server. hssh-serve is a testing web server enabled with hssh support.

Enable Node.JS webserver with hssh support

Use hssh as a module in node.js web application and attach hssh to node.js http.Server instance.

First install hssh as a module

npm i hssh --save

Use with http.Server:

var server=require("http").createServer(function handler(){});
require("hssh")(server);
server.listen(8080);

That's it! now the server is ready to be connected through hssh through:

hssh http://<server_host>:8080

Express

If express (>3.x) is used, simply do following:

var app=require("express")();
var server=require("http").Server(app);
require("hssh")(server);

//Define app routes

server.listen(8080);

Connect

Once you have both hssh client installed and node.js web-server enabled, you are ready to connect. Simply:

hssh <server_url>

For more usage, see hssh --help or Modules section below.

Modules

hssh is module based. All functionalities are plugable modules. This section gives the detailed usage of each module. Each module has 3 parts:

  • CLI parser: accept user input and convert into configuration
  • Client: manage local resource
  • Server: manage remote reosource

Shell

Shell module is base module of hssh. The module will be started automatically once connection succeed. This grants local shell access on remote server.

Command:

hssh <url>

Below graph shows how shell module works under the hood:

Change Bash

By default, hssh uses bash as remote bash in terminal. However, this can be changed to any type of bash. Set environment variable HSSH_SH to the bash wanted.

e.g. use sh

HSSH_SH=sh node ./my_hssh_server

Tunnel

You can forward port from remote to local:

hash -L <local_port>:<host>:<port> <server_url>

This will forward <host>:<port> from remote to local port <local_port> (same as how SSH -L works)

File Copy

You can copy file from / to remote using hcp command:

# copy from local to remote
hcp ./localfile http://<server_url>:/tmp/remotefile
# copy from remote to local
hcp http://<server_url>:/tmp/remotefile ./localfile

HSSH Configuration

hssh has a bunch of configurations:

  • User authentication
  • Welcome banner information

Just pass the parameter object as the second parameter when attaching to http.Server:

require("hssh")(server,params);

User Authentication

User authentication is customised. By default, there is not user authentication and any connection can run the bash. To add user authentication, simply add auth field to hssh parameters.

require("hssh")(server,{
	auth:function(auth,cb){
		//check auth.username and auth.password
		// once validated, call cb(true) or cb(false)
		// async auth is supported
	}
});

Once hssh server is configured with auth, hssh client will promt for username and password.

$ hssh http://127.0.0.1:8010
Connecting to  http://127.0.0.1:8010
Connection made
Waiting for welcome message...
Remote server requires login
Username: test
Password:

Welcome to HssH server
HssH Server version:  1.0.2
Server available modules:  shell,tunnel
bash-3.2$

If you want non-interactive, simply use --auth parameter:

$ hssh --auth test:test http://127.0.0.1:8010
Connecting to  http://127.0.0.1:8010
Connection made
Waiting for welcome message...
Remote server requires login
Login using --auth parameter
Welcome to HssH server
HssH Server version:  1.0.2
Server available modules:  shell,tunnel
bash-3.2$

Welcome banner text

Welcome banner text will be displayed in the welcome information

require("hssh")(server,{
	banner:"Welcome to my server"
});