Node.js SFTP server

I need to accept files by SFTP for users. I also need to dynamically create, update, destroy user accounts.

One way to accomplish this would be to install an SFTP server, and then write a script to handle editing/updating users.

After playing with Node.js a small amount, it seems like it would be good at this sort of thing. Any suggestions how to go about it, or modules that can accomplish this?

node-libssh can act as a SFTP server, see an example at: https://github.com/rvagg/node-libssh/blob/master/examples/stdiopipe.js

A common pattern in node.js is to create a node wrapper library around some service, which in your case is sftp. Take a look at the code (unfortunately lacking doumentation) node-sftp project:

https://github.com/ajaxorg/node-sftp

So, to recap, a very common thing is to create some HTTP-based API wrapper in node (perhaps using express) that then talks to some service on the system.

I don't know of any specific SFTP implementation, but this https://github.com/substack/node-ssh can probably be extended to support SFTP protocol on on an ssh connection.

SFTP works by using an SSH connection to carry the FTP protocol which is a text-based protocol.

I would start with this file: https://github.com/substack/node-ssh/blob/master/index.js And change the line matching the CHANNEL_REQUEST_SHELL and replace that with the correct constant and match the sftp protocol channel type.

You can probably reach substack on #node.js on freenode if you need more help with that.

(As an aside, there may be more support for this kind of thing with python with conch. The building blocks exist for node.js but there is no complete SFTP implmentation that I know of.)