Secure SSH transfers for Node.js

SCP-style commands backed by SFTP and a typed API.

scp-next uploads and downloads files or directories from a CLI, ESM import, or CommonJS require. Local and remote paths stay explicit, and sensitive values are redacted from logs and errors.

Upload from a local path to a remote path and download in the opposite direction

Features

One package for command-line transfers and reusable TypeScript integrations.

Files and directories

Upload and download individual files or recursive directory trees.

Typed configuration

Use profiles, jobs, environment variables, and explicit precedence.

Reusable clients

Connect once, transfer multiple paths, run commands, and close reliably.

ESM and CommonJS

Consume the same public API through import or require.

Dry-run planning

Resolve and validate CLI operations before connecting or transferring.

Host verification

Verify host keys with fingerprints or known-hosts files when configured.

Install

Install globally for CLI use or add the package to a Node.js project.

CLI

npm install --global scp-next
scp-next --help

Library

npm install scp-next

Usage

Upload uses a local source and remote destination. Download reverses that mapping.

CLI upload

scp-next upload ./dist /var/www/example \
  --host your-host \
  --username your-username \
  --recursive \
  --dry-run

TypeScript upload

import { upload } from "scp-next";

await upload({
  host: process.env.SCP_NEXT_HOST,
  username: process.env.SCP_NEXT_USERNAME,
  password: process.env.SCP_NEXT_PASSWORD,
  localPath: "./dist",
  remotePath: "/var/www/example",
  recursive: true
});
Credential safety: prefer environment variables, SSH agents, or protected private-key files. CLI password arguments may appear in shell history or process listings.

Install the documentation

Supported browsers can install this website, examples, and API reference for quick access. Installing the documentation does not install the npm package or grant SSH access.