1.1.0 • Published 4 years ago

ssh2-sftp-server-linux v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

ssh2-sftp-server : SFTP server for node.js - FIXED to work in linux

FORK OF:

ssh2-sftp-server is sftp server module written in pure JavaScript it use excellent ssh2 library by Brian White.

Version License

Installation

npm install ssh2-sftp-server

Supported API

support most of client requests:

  • OPEN
  • CLOSE
  • REALPATH
  • STAT
  • OPENDIR
  • READ
  • REMOVE
  • RMDIR
  • MKDIR
  • RENAME
  • READDIR
  • WRITE

Usage

"use strict";

const fs         = require('fs');
const {Server}   = require('ssh2');
const SftpServer = require('ssh2-sftp-server');

new ssh2.Server({
  hostKeys: [fs.readFileSync('host.key')]
}, function(client) {
  client.on('authentication', function(ctx) {
    ctx.accept();
  }).on('ready', function() {
    client.on('session', (accept) => {
      let session = accept();
      session.on('sftp', function() {
        var sftpStream = accept();
        new SftpServer(sftpStream);
      });
    });
  });
});

Credits