Repository navigation
A rewrite. The 0.x API is still available from node-scp/legacy; see
docs/migration/from-0.x.md.
Breaking changes
- New API:
connect()returns a client withupload,download,writeFile,readFileand
fs. The 0.xClientmoved tonode-scp/legacy. - Every error is a
ScpErrorwith a stablecodeand the original error ascause. - Destinations are exact paths, and remote parent directories must exist.
- Node.js 20 or newer is required.
Features
- Real SCP protocol support for servers without SFTP, such as Dropbear, OpenWrt and network
devices.protocol: 'auto'(the default) prefers SFTP and falls back to SCP. - Transfer options for both protocols:
recursive,concurrency,filter,preserve,
onProgressandsignal. writeFileandreadFilefor buffers and streams. A stream withsizemust match it
exactly, otherwise the write fails withERR_INVALID_ARGUMENT.await usingsupport throughSymbol.asyncDispose.- One shot
upload()anddownload()helpers that takeuser@host:path. TCP_NODELAYby default, which makes many small transfers an order of magnitude faster.node-scp/scp2, a drop in replacement for the unmaintainedscp2package.- A
node-scpcommand line tool and a GitHub Action. - ES modules and CommonJS builds with bundled types, published with npm provenance.
- ssh2 updated to ^1.17.0.
Fixes
- Names received from the server, in SCP records and SFTP directory listings, are validated,
so a malicious server cannot write outside the destination. - New copies get the source permission bits over both protocols, like
scpandsftp.
setuid, setgid and sticky bits only travel withpreserve. - Connection errors after
readyno longer crash the process when nobody listens forerror. - The
greetingevent is no longer emitted asbanner.