Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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)
'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',
function genPublicKey() {
const pubKey = fs.readFileSync(resolve(__dirname, 'fixtures', 'keys', 'ssh.public'))
return ssh2.utils.genPublicKey(ssh2.utils.parseKey(pubKey))
}
'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');
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 {
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) {
'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
'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