npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-git-ssh

v1.0.1

Published

Use git over SSH in Node.js environments without system git or ssh binaries (dugite + ssh2)

Readme

node-git-ssh

Use git over SSH in Node.js without any system git or ssh binaries.

Works in sandboxed environments (Docker containers, serverless functions, restricted CI) where you only have Node.js available.

Built on:

  • dugite — bundles a full git binary as an npm package
  • ssh2 — pure JavaScript SSH client

Why?

Some environments (e.g. minimal Docker images, sandboxed runtimes, OpenClaw agent containers) have Node.js but no git or ssh binaries. This package bridges the gap.


Installation

npm install node-git-ssh
# or
yarn add node-git-ssh

Usage

Generate a key pair

const { generateKeyPair } = require('node-git-ssh');

const { privateKey, publicKey } = generateKeyPair('my-app');

console.log(publicKey);
// ssh-ed25519 AAAAC3... my-app
// → Add this to your GitHub/GitLab account SSH keys

Clone a repository

const { clone } = require('node-git-ssh');
const fs = require('fs');

const privateKey = fs.readFileSync('/path/to/id_ed25519', 'utf8');

clone(
  '[email protected]:user/repo.git',
  '/local/destination',
  { privateKey, depth: 1 }
);

Fetch & push

const { fetch, push } = require('node-git-ssh');

fetch('/path/to/repo', { privateKey });
push('/path/to/repo', { privateKey, branch: 'main' });

Run any git command

const { gitWithSSH } = require('node-git-ssh');

const result = gitWithSSH(
  ['log', '--oneline', '-10'],
  { privateKey, cwd: '/path/to/repo', stdio: 'pipe' }
);

console.log(result.stdout);

API

generateKeyPair(comment?)

Generates an ed25519 key pair in OpenSSH format.

  • Returns { privateKey: string, publicKey: string }
  • publicKey is in OpenSSH authorized_keys format — paste it directly into GitHub/GitLab

clone(url, destination, options)

Clones a repository.

  • url — SSH git URL (e.g. [email protected]:user/repo.git)
  • destination — local path
  • options.privateKey — OpenSSH PEM private key string
  • options.depth — (optional) shallow clone depth
  • options.branch — (optional) branch to clone

fetch(repoPath, options)

Fetches all remotes.

push(repoPath, options)

Pushes to a remote.

  • options.remote — default 'origin'
  • options.branch — (optional)

gitWithSSH(args, options)

Runs an arbitrary git command with SSH authentication.

  • Returns { status, stdout, stderr }

getGitBinary()

Returns the path to the bundled git binary.

getGitExecPath()

Returns the path to git's libexec directory.


How it works

  1. dugite provides a pre-compiled git binary bundled as an npm package — no system git needed.
  2. A temporary shell script is written to $TMPDIR and set as GIT_SSH.
  3. That script calls a Node.js process using ssh2 to handle the SSH connection and authenticate with the provided key.
  4. git's GIT_EXEC_PATH is pointed at dugite's libexec/git-core so internal git tools (like index-pack) are found.

The private key never touches disk as a persistent file — it's written to a temp file for the duration of the command and deleted immediately after.


Caveats

  • Only SSH URLs are supported (not HTTPS). For HTTPS, just use the native https module or isomorphic-git.
  • Host key verification is skipped (hostVerifier: () => true). For production use, implement proper host key pinning.
  • Tested on Linux (x64). Should work on macOS. Windows support depends on dugite's platform support.

License

MIT