gitmyhub

ssh2

JavaScript ★ 5.8k updated 1mo ago

SSH2 client and server modules written in pure JavaScript for node.js

A Node.js library that implements SSH entirely in JavaScript, connect to remote servers, run commands, transfer files over SFTP, set up port forwarding, or build your own custom SSH server.

JavaScriptNode.jssetup: easycomplexity 3/5

This is a Node.js library that lets JavaScript programs connect to remote servers over SSH, or act as an SSH server themselves. SSH is the standard protocol used to securely log into and run commands on remote computers. This library implements that protocol entirely in JavaScript without relying on any native system SSH installation.

On the client side, the library can do everything a normal SSH client does. You can connect to a remote server, run a single command and get its output back, or open an interactive shell session. It also supports SFTP, which is the file transfer protocol that runs over SSH, letting you list directories, upload and download files on a remote machine. Port forwarding is supported in both directions: you can tunnel traffic from your local machine through the SSH connection to reach services on the remote server, or have the remote server forward traffic back to your local machine. There is also support for X11 forwarding (for graphical applications), SOCKS proxy connections, and using SSH tunnels as the underlying transport for regular HTTP or HTTPS requests.

On the server side, the library lets you build a custom SSH server in Node.js. You can define how the server handles authentication, whether via password or SSH key pairs. The server can accept interactive shell connections, run specific commands sent by clients, and serve as an SFTP-only endpoint for file transfers.

Installation is a single npm command. The library requires Node.js version 10.16.0 or newer. Support for Ed25519 key types requires version 12 or newer. An optional native addon called cpu-features can be installed alongside it to improve cipher selection performance, but it is not required.

The library is tested against OpenSSH, the most widely deployed SSH implementation. The full README is longer than what was shown.

Where it fits