ssh2-sftp-server

SSH2 sftp server

Usage no npm install needed!

<script type="module">
  import ssh2SftpServer from 'https://cdn.skypack.dev/ssh2-sftp-server';
</script>

README

ssh2-sftp-server : SFTP server for node.js

Works in win32 and linux style.

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

Build Status Version

License Code style

Available platform Available platform

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