Works where SFTP does not
protocol: 'auto' uses SFTP when the server offers it and falls back to SCP, so Dropbear, routers and switches just work.
How it picks
SFTP when the server has it, the real SCP protocol when it does not. One small API for cloud VMs, OpenWrt routers and network gear.
import { connect } from 'node-scp';
await using client = await connect({ host: 'example.com', username: 'deploy', privateKey });
await client.upload('./dist', '/var/www/app', { recursive: true });import { upload } from 'node-scp';
await upload('./dist', 'deploy@example.com:/var/www/app', { recursive: true, privateKey });npx node-scp -r ./dist deploy@example.com:/var/www/app- uses: maitrungduc1410/node-scp-async@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: deploy
private-key: ${{ secrets.DEPLOY_KEY }}
source: dist/
target: /var/www/appPick a server to see what node-scp does with it.
protocol: 'auto' usesSFTPclient.fsavailableThe common case. Nothing to configure.
await connect({ host: 'example.com', username: 'deploy', privateKey });Uploads to OpenSSH on the same machine, mean of several runs. Most of the gap on small files comes from TCP_NODELAY; the comparison page explains it.