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,825 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
56 /100 Fair
Development Activity 32
Maintenance 8
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
80 /100 Excellent
Architecture 82
Code Quality 78
Innovation 74
Learning Curve 85

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 18 apps in this directory

TypeScript
97%
Other

Lightdash

Analytics · Data Engineering

6,196

The open-source Looker alternative that turns your dbt project's metrics and dimensions into governed, self-serve charts and dashboards — no license key required.

View details
93
Repo Health
84
Technical
64
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
88%
Apache 2.0

Medplum

Authentication · Databases · Developer Tools

2,760

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
71
Dependency
Built with
TypeScript 88%
Updated 6 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 1 weeks ago
TypeScript
93%
Apache 2.0

Openship

Devops · Hosting Control Panel

14,912

Openship is an open-source, self-hostable deployment platform that points at a repo and builds, ships, routes, and TLS-terminates the app — driven from a desktop app, web dashboard, or CLI.

View details
84
Repo Health
85
Technical
65
Dependency
Built with
TypeScript 93%
Updated 6 days ago
TypeScript
96%
MIT

Orca

AI Agents · AI Code Assistants

104,104

An open-source Agent Development Environment that orchestrates fleets of parallel AI coding agents — Claude Code, Codex, Gemini and more — each running in its own isolated git worktree.

View details
84
Repo Health
85
Technical
74
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
93%
MIT

paperclip

AI Agents · Automation

106,667

The open-source control plane that turns a pile of AI agents into an actual company — with org charts, budgets, heartbeats, and governance.

View details
86
Repo Health
78
Technical
68
Dependency
Built with
TypeScript 93%
Updated 6 days ago
TypeScript
94%
Other

Termix

Devops

15,644

Manage all your servers — SSH terminals, remote desktops, file transfers, and Docker containers — from a single self-hosted browser interface.

View details
84
Repo Health
67
Technical
73
Dependency
Built with
TypeScript 94%
Updated 1 weeks ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 6 days ago
TypeScript
41%
AGPL 3.0

Wiki.js

Collaboration · Knowledge Management

29,081

A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.

View details
95
Repo Health
67
Technical
60
Dependency
Built with
TypeScript 41%
Vue 39%
JavaScript 16%
Updated 6 days ago

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