Skip to content

runSshCommand

function runSshCommand(options: RunSshCommandOptions): Promise<RunSshCommandResult>;

Defined in: src/protocols/ssh/runSshCommand.ts:86

Connects, authenticates, runs command on a fresh exec channel, drains stdout, and disconnects. The TCP socket, transport, auth session, and channel are all owned by this helper and torn down before it returns.

ParameterType
optionsRunSshCommandOptions

Promise<RunSshCommandResult>

import { runSshCommand } from "@zero-transfer/ssh";
const { stdoutText } = await runSshCommand({
host: "ssh.example.com",
auth: { type: "password", username: "deploy", password: process.env.SSH_PASSWORD! },
command: "uname -a",
});
console.log(stdoutText);