ssh2

Pure-JavaScript SSH2 client and server library for Node.js, with SFTP, exec, shell, and port forwarding support.

Library
npm
v1.17.0
5,813stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity36
Maintenance16
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture82
Code Quality78
Innovation74
Learning Curve85

ssh2 is a pure-JavaScript implementation of the SSH2 protocol for Node.js, providing both client and server capabilities without shelling out to system SSH binaries. It supports command execution, interactive shells, SFTP file transfer, local/remote/dynamic TCP forwarding, X11 forwarding, and custom subsystems, all through an EventEmitter-based API built directly on top of Node’s net.Socket.

Because it implements the wire protocol itself — key exchange, ciphers, MACs, compression, and authentication — ssh2 gives applications fine-grained control over connection behavior (algorithm negotiation, host key verification, keyboard-interactive auth) that shelling out to the OpenSSH client can’t offer, making it a common building block for remote automation tools, deployment scripts, and SFTP-backed file services.

What You Get

  • A Client class for connecting to SSH servers with exec, shell, SFTP, and forwarding support
  • A Server class for building SSH-accessible services (custom shells, git-over-ssh, SFTP endpoints)
  • A full SFTP protocol implementation for uploads, downloads, and directory operations
  • Key generation and parsing utilities supporting RSA, ED25519, and ECDSA formats
  • HTTPAgent/HTTPSAgent classes that tunnel Node’s http/https clients through an SSH connection
  • Building blocks for dynamic (SOCKS-style) and remote port forwarding, plus X11 forwarding

Common Use Cases

  • Automating remote server administration — running commands, checking status, deploying code
  • Building SFTP-backed file transfer, sync, or backup services
  • Implementing a custom SSH-accessible CLI or git-over-ssh style server
  • Tunneling HTTP requests or arbitrary TCP traffic over an SSH connection
  • Chaining connections through jump/bastion hosts to reach hosts on private networks

Under The Hood

Architecture ssh2 is layered around lib/protocol/Protocol.js, a low-level state machine that frames and parses SSH2 binary packets, sitting directly on Node’s net.Socket. Above it, lib/protocol/kex.js and lib/protocol/crypto.js handle key exchange, cipher/MAC negotiation, and encryption using Node’s crypto module (with an optional native cpu-features addon compiled via node-gyp to pick optimal ciphers). lib/client.js and lib/server.js wrap the protocol layer in EventEmitter-based Client/Server classes that expose high-level operations (exec, shell, forwardOut, sftp), while lib/Channel.js implements SSH channel multiplexing (window sizing, flow control) shared by both exec/shell streams and forwarded connections. The SFTP subsystem is its own protocol implementation in lib/protocol/SFTP.js (4,000+ lines) layered on top of a channel, and lib/agent.js separately implements the SSH agent protocol (OpenSSH, Pageant, Cygwin variants) for forwarded-agent authentication.

Tech Stack The library is written entirely in plain JavaScript (CommonJS, no TypeScript) targeting Node.js >=16, with only two runtime dependencies (asn1, bcrypt-pbkdf) and two optional native dependencies (cpu-features, nan) that are compiled at install time via install.js/node-gyp but degrade gracefully to pure-JS crypto if the build fails. There’s no bundler or build step for the library itself since it ships as-is for Node consumption; linting is handled by a shared @mscdex/eslint-config ESLint setup.

Code Quality The test/ directory contains a substantial, protocol-focused suite driven by a custom test/test.js orchestrator, with dedicated files for SFTP (test-sftp.js), key generation, protocol crypto, key parsing, user auth, server host keys, and even integration tests that exercise a real OpenSSH server (test-integration-openssh.js, test-openssh.js). Error handling favors explicit err callback arguments and emitted 'error' events over exceptions, consistent with Node’s streams/EventEmitter conventions, and naming is consistent across the client/server halves of the API (mirrored method and event names).

API Design The public surface follows familiar Node idioms — Client and Server extend EventEmitter, connections resolve via a 'ready' event, and operations like exec/shell/sftp use Node-style (err, stream) callbacks rather than promises, which keeps it consistent with older Node APIs but means promise/async-await usage requires manual wrapping. The README (70KB+) and separate SFTP.md document nearly every event, method, and option exhaustively with runnable examples for common scenarios (exec, shell, forwarding, SFTP, connection hopping, X11), which lowers the ramp-up cost despite the library’s large surface area and lack of bundled TypeScript definitions (community @types/ssh2 fills that gap separately).

Used by 19 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
65
Dependency
Built with
TypeScript99%
Updated today
Go
92%
AGPL 3.0

BillionMail

Marketing

15,424

Self-hosted email server and marketing platform that gives you unlimited sending, full deliverability control, and AI-assisted campaigns without monthly fees.

View details
59
Repo Health
74
Technical
73
Dependency
Built with
Go92%
Updated 2 months ago
TypeScript
96%
Other

CapRover

Developer Tools · Devops · Hosting Control Panel

15,132

Deploy any app, database, or website to your own server in minutes—no Docker or Linux expertise required.

View details
87
Repo Health
82
Technical
69
Dependency
Built with
TypeScript96%
Updated 3 days ago
TypeScript
99%
MIT

Cate

AI Code Assistants

2,087

A desktop IDE built on an infinite canvas — spread code editors, terminals, browsers, docs, and AI agents across freeform space instead of stacking windows and tabs, with layouts restored automatically.

View details
79
Repo Health
71
Technical
72
Dependency
Built with
TypeScript99%
Updated today
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,041

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
65
Dependency
Built with
JavaScript99%
Updated 6 days ago
Go
76%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,199

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
71
Dependency
Built with
Go76%
TypeScript22%
Updated today
TypeScript
99%
Other

Dokploy

Devops · Hosting Control Panel · Security

36,702

Self-hosted PaaS that deploys apps and databases on your own VPS using Docker, Traefik, and multi-build-system orchestration

View details
89
Repo Health
76
Technical
65
Dependency
Built with
TypeScript99%
Updated yesterday
TypeScript
97%
Other

Infisical

Security · Devops

28,838

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
66
Dependency
Built with
TypeScript97%
Updated today
TypeScript
98%
MIT

Kimi Code CLI

AI Code Assistants · AI Agents · Developer Tools

6,908

A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.

View details
81
Repo Health
87
Technical
66
Dependency
Built with
TypeScript98%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search