node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

sshconf

sshconf

sshconf is a robust, streaming ssh config parser.

Build status

Install

$ npm install sshconf

Usage

var fs = require('fs')
var parse = require('sshconf/parse')
var through = require('through2')
 
fs.createReadStream('/path/to/ssh_config')
  .pipe(parse())
  .pipe(stringify())
  .pipe(process.stdout)
 
function stringify () {
  return through.obj(function (json, enc, next) {
    next(null, JSON.stringify(json) + '\n')
  })
}

Get parsed data as a single object

var fs = require('fs')
var parse = require('sshconf/parse')
var merge = require('sshconf/merge')
 
fs.createReadStream('/path/to/ssh_config')
  .pipe(parse())
  .pipe(merge(function (err, parsed) {
    console.log(JSON.stringify(parsed, null, 2))
  }))

License

MIT