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

prossh

v0.1.1

Published

Promise wrapper + some additional functionality for SSH2

Downloads

3

Readme

prossh

Promised SSH2 Client wrapper

Installation

yarn add prossh

Examples

Execute uptime on a server

var client = require('prossh').client

client({
  host: '192.168.100.100',
  port: 22,
  username: 'frylock',
  privateKey: require('fs').readFileSync('/here/is/my/key')
}).then(conn => {
  console.log('Client :: ready')
  return conn.exec('uptime')
}).then(uptime => {
  console.log('Client :: ready')
  return conn.exec('uptime').then(uptime => {
    uptime.stdout.on('data', data => console.log("STDOUT : " + data))
    uptime.stderr.on('data', data => console.log("STDERR : " + data))
    return uptime.result
  }).then(({code, signalName}) => {
    console.log('Stream :: exit :: code: ' + code + ', signal: ' + signalName)
    conn.end()
  }) 
})

// example output:
// Client :: ready
// STDOUT : 10:46  up  9:59, 4 users, load averages: 1.99 1.80 1.75
// 
// Stream :: exit :: code: 0, signal: undefined

Start an interactive shell session

var client = require('prossh').client

client({
  host: '192.168.100.100',
  port: 22,
  username: 'frylock',
  privateKey: require('fs').readFileSync('/here/is/my/key')
}).then(conn => {
  console.log('Client :: ready')
  return conn.shell({pty: true}).then(shell => {
    shell.stdout.on('data', data => console.log("STDOUT : " + data))
    shell.stderr.on('data', data => console.log("STDERR : " + data))
    shell.stream.end('ls -l\nexit\n')
    return shell.result
  }).then(() => {
    console.log('Stream :: close')
    conn.end()
  })
})

// example output:
// Client :: ready
// STDOUT: Last login: Sun Jun 15 09:37:21 2014 from 192.168.100.100
//
// STDOUT: ls -l
// exit
//
// STDOUT: frylock@athf:~$ ls -l
//
// STDOUT: total 8
//
// STDOUT: drwxr-xr-x 2 frylock frylock 4096 Nov 18  2012 mydir
//
// STDOUT: -rw-r--r-- 1 frylock frylock   25 Apr 11  2013 test.txt
//
// STDOUT: frylock@athf:~$ exit
//
// STDOUT: logout
//
// Stream :: close

Send a raw HTTP request to port 80 on the server

var client = require('./lib/index.js').client

client({
  host: '192.168.100.100',
  port: 22,
  username: 'frylock',
  privateKey: require('fs').readFileSync('/here/is/my/key')
}).then(conn => {
  console.log('Client :: ready')
  return conn.forwardOut({host: '127.0.0.1', port: 80}).then(stream => {
    stream.on('close', () => {
      console.log('TCP :: CLOSED')
      conn.end()
    }).on('data', data => console.log('TCP :: DATA: ' + data))
      .end([
        'HEAD / HTTP/1.1',
        'User-Agent: curl/7.27.0',
        'Host: 127.0.0.1',
        'Accept: */*',
        'Connection: close',
        '',
        ''
      ].join('\r\n'))
  })
})

// example output:
// Client :: ready
// TCP :: DATA: HTTP/1.1 200 OK
// Date: Thu, 15 Nov 2012 13:52:58 GMT
// Server: Apache/2.2.22 (Ubuntu)
// X-Powered-By: PHP/5.4.6-1ubuntu1
// Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
// Content-Encoding: gzip
// Vary: Accept-Encoding
// Connection: close
// Content-Type: text/html; charset=UTF-8
//
//
// TCP :: CLOSED

Forward local connections to port 8000 on the server to us

var client = require('./lib/index.js').client

client({
  host: '192.168.100.100',
  port: 22,
  username: 'frylock',
  privateKey: require('fs').readFileSync('/here/is/my/key')
}).then(conn => {
  console.log('Client :: ready')
  return conn.forwardIn(8080).then(server => {
    console.log('Listening for connections on server on port 8000!');
    server.on('connection', socket => {
      console.log('TCP :: INCOMING CONNECTION:')
      console.dir({
        destIP: socket.localAddress,
        destPort: socket.localPort,
        srcIP: socket.remoteAddress,
        srcPort: socket.remotePort
      })
      socket.on('close', () => console.log('TCP :: CLOSED'))
        .on('data', data => console.log('TCP :: DATA: ' + data))
        .end([
          'HTTP/1.1 404 Not Found',
          'Date: Thu, 15 Nov 2012 02:07:58 GMT',
          'Server: ForwardedConnection',
          'Content-Length: 0',
          'Connection: close',
          '',
          ''
        ].join('\r\n'))
    })
  })
})

// example output:
// Client :: ready
// Listening for connections on server on port 8000!
//  (.... then from another terminal on the server: `curl -I http://127.0.0.1:8000`)
// TCP :: INCOMING CONNECTION: { destIP: '127.0.0.1',
//  destPort: 8000,
//  srcIP: '127.0.0.1',
//  srcPort: 41969 }
// TCP DATA: HEAD / HTTP/1.1
// User-Agent: curl/7.27.0
// Host: 127.0.0.1:8000
// Accept: */*
//
//
// TCP :: CLOSED

Get a directory listing via SFTP

To be continued

Connection hopping

TODO

Forward remote X11 connections

Test required

Dynamic (1:1) port forwarding using a SOCKSv5 proxy (using socksv5)

Test required

Invoke an arbitrary subsystem

To be continued