How to use the ssh2.SFTP_STATUS_CODE 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 pterodactyl / daemon / src / http / sftp.js View on Github external
const Fs = require('fs-extra');
const rfr = require('rfr');
const Async = require('async');
const _ = require('lodash');
const Ssh2 = require('ssh2');
const Moment = require('moment');
const Util = require('util');
const Ssh2Streams = require('ssh2-streams');
const Path = require('path');
const Randomstring = require('randomstring');
const Request = require('request');

const SftpStream = Ssh2Streams.SFTPStream;
const OPEN_MODE = Ssh2.SFTP_OPEN_MODE;
const STATUS_CODE = Ssh2.SFTP_STATUS_CODE;

const Log = rfr('src/helpers/logger.js');
const ConfigHelper = rfr('src/helpers/config.js');
const Servers = rfr('src/helpers/initialize.js').Servers;
const SFTPQueue = rfr('src/helpers/sftpqueue.js');
const Config = new ConfigHelper();

class InternalSftpServer {
    init(next) {
        Ssh2.Server({
            algorithms: { compress: Config.get('sftp.algos.compress', ['none', 'zlib']) },
            hostKeys: [
                Fs.readFileSync(Config.get('sftp.keypair.hostkey_path', './config/.sftp/id_rsa')).toString('utf8'),
            ],
        }, client => {
            let clientContext;
github mscdex / ssh2 / examples / sftp-server-download-only.js View on Github external
var crypto = require('crypto');
var constants = require('constants');
var fs = require('fs');

var ssh2 = require('ssh2');
var OPEN_MODE = ssh2.SFTP_OPEN_MODE;
var STATUS_CODE = ssh2.SFTP_STATUS_CODE;

var allowedUser = Buffer.from('foo');
var allowedPassword = Buffer.from('bar');

new ssh2.Server({
  hostKeys: [fs.readFileSync('host.key')]
}, function(client) {
  console.log('Client connected!');

  client.on('authentication', function(ctx) {
    var user = Buffer.from(ctx.username);
    if (user.length !== allowedUser.length
        || !crypto.timingSafeEqual(user, allowedUser)) {
      return ctx.reject(['password']);
    }
github tkambler / sftp-server / lib / components / stream-manager / index.js View on Github external
'use strict';

const SFTPStream  = require('ssh2-streams').SFTPStream;
const sftpStreamExtensions = require('./sftp-stream-extensions');
const sftpEvents = require('./sftp-events');
const _ = require('lodash');
const ssh2 = require('ssh2');
const STATUS_CODE = ssh2.SFTP_STATUS_CODE;
const path = require('path');
const moment = require('moment');

exports = module.exports = function(fs, config, log) {

    const DirAdapter = require('./adapters/dir')({ 'fs': fs, 'config': config, 'log': log });
    const FileReader = require('./adapters/file-reader')({ 'fs': fs, 'config': config, 'log': log });
    const FileWriter = require('./adapters/file-writer')({ 'fs': fs, 'config': config, 'log': log });

    class StreamManager {

        constructor(clientManager, client, stream) {

            log.debug('Initializing StreamManager');

            this.clientManager = clientManager;