How to use the ssh2.utils function in ssh2

To help you get started, we’ve selected a few ssh2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngnjs / NGN / test / 04-sshtunnel.js View on Github external
'use strict'

const LOCAL_PORT = parseInt(process.env.LOCAL_SSH_PORT || 47911, 10) - 3
const REMOTE_PORT = parseInt(process.env.LOCAL_SSH_PORT || 47911, 10) - 5
const test = require('tape')
const fs = require('fs')
const path = require('path')
const net = require('net')
const crypto = require('crypto')
const ssh2 = require('ssh2')
const utils = ssh2.utils
const buffersEqual = require('buffer-equal-constant-time')

const createServer = function () {
  return net.createServer(function (c) { // 'connection' listener
    console.log('remote client connected')
    c.on('data', function (d) {
      console.log('DATA', d)
    })
    c.on('end', function () {
      console.log('remote client disconnected')
    })
    c.on('close', function () {
      console.log('mock TCP server closed.')
    })
    c.write('hello\r\n')
//    c.pipe(c)
github kzwang / node-git-lfs / test / authenticator / basic.js View on Github external
'use strict';

var crypto = require('crypto');
var fs = require('fs');
var ssh_utils = require('ssh2').utils;

var should = require('chai').should();




var BasicAuthenticator = require('../../lib/authenticator/basic');


describe('Basic Authenticator', function() {

    var authenticator;

    beforeEach(function() {
       authenticator = new BasicAuthenticator({
           username: 'testuser',
github nuxt / fabula / test / server.js View on Github external
function genPublicKey() {
  const pubKey = fs.readFileSync(resolve(__dirname, 'fixtures', 'keys', 'ssh.public'))
  return ssh2.utils.genPublicKey(ssh2.utils.parseKey(pubKey))
}
github hmngwy / weblog.sh / lib / ssh / auth.js View on Github external
'use strict';

var buffersEqual = require('buffer-equal-constant-time');
var utils = require('ssh2').utils;
var schemas = require('../schemas');
var mongoose = require('mongoose');

module.exports = function(userMeta) {
  return function(ctx) {

    console.log(' **  '+ctx.username+' initiated');
    if(ctx.username === undefined) {
      console.log(' **  rejecting nameless login', ctx.method);
      ctx.reject();
      return;
    }

    console.log(' **  authenticating with method', ctx.method);
    if(ctx.method === 'keyboard-interactive') {
      console.log(' **  keyboard-interactive auth is disabled');
github mscdex / ssh-repl / lib / index.js View on Github external
const repl = require('repl');
const crypto = require('crypto');
const Transform = require('stream').Transform;
const inherits = require('util').inherits;
const inspect = require('util').inspect;

const ssh2 = require('ssh2');
const Server = ssh2.Server;
const genPublicKey = ssh2.utils.genPublicKey;
const parseKey = ssh2.utils.parseKey;

module.exports = function createServer(cfg, cb) {
  if (typeof cfg !== 'object' || cfg === null)
    throw new Error('Missing/Invalid configuration');
  const srv = new Server(cfg.server);
  if (typeof cfg.port !== 'number')
    throw new Error('Missing/Invalid port');
  if (typeof cfg.users !== 'object' && typeof cfg.users !== 'function')
    throw new Error('Missing/Invalid users configuration');

  const users_ = cfg.users;
  var users;
  if (typeof users_ === 'function')
    users = users_;
  else {
github mscdex / ssh-repl / lib / index.js View on Github external
const repl = require('repl');
const crypto = require('crypto');
const Transform = require('stream').Transform;
const inherits = require('util').inherits;
const inspect = require('util').inspect;

const ssh2 = require('ssh2');
const Server = ssh2.Server;
const genPublicKey = ssh2.utils.genPublicKey;
const parseKey = ssh2.utils.parseKey;

module.exports = function createServer(cfg, cb) {
  if (typeof cfg !== 'object' || cfg === null)
    throw new Error('Missing/Invalid configuration');
  const srv = new Server(cfg.server);
  if (typeof cfg.port !== 'number')
    throw new Error('Missing/Invalid port');
  if (typeof cfg.users !== 'object' && typeof cfg.users !== 'function')
    throw new Error('Missing/Invalid users configuration');

  const users_ = cfg.users;
  var users;
  if (typeof users_ === 'function')
    users = users_;
  else {
    users = function usersWrapper(user, callback) {
github hmngwy / weblog.sh / lib / ssh-server.js View on Github external
'use strict';

var ssh2 = require('ssh2');
var utils = ssh2.utils;
var Server = ssh2.Server;
var fs = require('fs');

var LB = "\n\r";

/*
# register
$ ssh edward@weblog.sh

# browse drafts
$ ssh edward@weblog.sh fetch draft

# browse published
$ ssh edward@weblog.sh fetch published

# create new and upload on save
github kzwang / node-git-lfs / lib / authenticator / basic.js View on Github external
'use strict';

var _ = require('lodash');
var fs = require('fs');
var crypto = require('crypto');
var ssh_utils = require('ssh2').utils;

var Authenticator = require('./');

/**
 * RegExp for basic auth credentials
 *
 * credentials = auth-scheme 1*SP token68
 * auth-scheme = "Basic" ; case insensitive
 * token68     = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="
 * @private
 */
const CREDENTIALS_REG_EXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9\-\._~\+\/]+=*) *$/;


/**
 * RegExp for basic auth user/pass