The ssh2 npm package implements SSH client and server protocols for Node.js with channels, SFTP, forwarding, and agents.
Overview
ssh2 provides Client and Server constructors written entirely in JavaScript for Node.js environments. Development tracks compatibility with contemporary OpenSSH releases.
Client APIs cover remote command execution, interactive shells, SFTP directory listings, local and remote TCP forwarding, X11 forwarding, SOCKS proxies, and custom subsystems. Server examples show password, public key, and keyboard-interactive authentication flows plus SFTP-only hosts.
Utility modules parse keys, integrate with OpenSSH agents on Unix, Pageant on Windows, and Cygwin agents, and expose HTTP and HTTPS agents that tunnel over SSH.
Bundled examples illustrate connection hopping and advanced forwarding patterns. Consumers embed the library in deployment tools, bastion services, or test harnesses.
Key features
- Node.js SSH client and server
- Interactive shell and exec channels
- SFTP and subsystem support
- Local and remote port forwarding
- OpenSSH agent integration
- Custom cipher algorithm lists
- HTTP agents over SSH tunnels
- Extensive API event model
Use cases
- Building Node deployment tools
- Embedded SFTP services
- Automating remote commands
- SSH bastion prototypes