node-libssh
libssh
A Low-level Node.js binding forCurrently this project is only concerned with a subset of the server functionality provided by libssh. The client functionality may be added at a future date (and you're invited to contribute if you want it!).
You can find it in npm as ssh, (version 0.0.1 of which is substack's version with an older libssh).
Installing
To compile, you'll need to have libkrb5-dev (kerberos development files) and libssl-dev (openssl development files) installed on your system. npm install ssh
should do the rest.
Lets make a Node.js SSH server!
var server = libssh server server // required port and optional ipv4 address interface defaults to 0.0.0.0console
See stdiopipe.js in the examples directory if you want to try this out.
Remote exec!
We can receive exec requests and send the results back to the client. In this example we'll allow any exec if you have the right publickey.
// a simple exec utility that spawns a process and pipes stdio to// back to the channel { var cmdarr = cmd child = childstdout child} server
See exec.js in the examples directory if you want to try this out.
How about some SFTP goodness?
server
See trickysftp.js in the examples directory if you want to try this out.
SFTP events include:
- sftp:open
- sftp:close
- sftp:read
- sftp:write
- sftp:lstat
- sftp:fstat
- sftp:setstat
- sftp:fsetstat
- sftp:opendir
- sftp:readdir
- sftp:remove
- sftp:mkdir
- sftp:rmdir
- sftp:realpath
- sftp:stat
- sftp:rename
- sftp:readlink
- sftp:symlink
See the test files for more usage examples.
Stat
TODO: document this...
Important project notes
This project is very new and immature and is bound to have some warts. There are a few known, minor memory leaks that need to be addressed. While node-libssh makes use of both libssh's nonblocking I/O facilities and libuv's socket polling, it's likely that there could be more performance gained from some more async work within the binding code.
The streams do not implement back-pressure very well, particularly the read component of channel stream which will just keep on filling up its buffer.
Please file issues if you have any questions or concerns or want to see a particular area focused on for development—just don't expect me to be able to justify time developing or fixing your own pet features, contributions would be greatly appreciated no matter how much of a n00b you feel.
If you want to see more of what's going on, you can send a debug:true
option when you make a new Server
instance, it'll print out some message details. There's additional debug cruft you can enable in the source but you'll have to dig to find that and it's very noisy.
Contributing
node-libssh is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the CONTRIBUTING.md file for more details.
Maintainers
- Rod Vagg @rvagg
- Brian White @mscdex
- Audrius Butkevicius @AudriusButkevicius
- Darius Clark @dariusc93
Licence & copyright
Copyright (c) 2013-2014 Rod Vagg and Maintainers (above)
node-libssh is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
*node-libssh builds on the excellent work of the libssh team. libssh is licensed under the LGPLv2.