@xec-sh/ssh
v0.13.2
Published
Typed SSH connections, channels, transfers and tunnels using native runtime cryptography
Readme
@xec-sh/ssh
Typed SSH clients, connection leases, channels, SFTP and forwarding. One package owns the protocol and resource lifetimes; Xec Core supplies command execution and target policy.
Development: this package is being introduced for Xec 0.13.0. It is not part of the published 0.12.0 distribution.
import { SSHClient } from '@xec-sh/ssh';
const agent = process.env.SSH_AUTH_SOCK;
if (!agent) throw new Error('An SSH agent socket is required');
const ssh = await new SSHClient().connect({
host: 'build.example.net',
username: 'builder',
agent,
hostKeyChecking: 'strict',
});
try {
const result = await ssh.exec('uname -s', { signal: AbortSignal.timeout(10_000) });
if (result.code !== 0) throw new Error('Remote inspection failed');
process.stdout.write(result.stdout);
} finally {
ssh.dispose();
}Provision the server key in known_hosts before connecting. The client preserves
stdout, stderr and remote exit information; a lost acknowledgement is an unknown
outcome, not permission to replay a command. Use Core's $.ssh tagged templates
when interpolating command arguments.
- Native runtime cryptography; no compiled addon, installation build or bundled
ssh2. - Strict host trust, bounded operations and explicit connection leases.
- Unencrypted PEM, bounded encrypted OpenSSH keys and agents; encrypted PEM/PKCS8 is rejected before native parsing.
- Streams, PTYs, SFTP and tunnels share one lifecycle implementation.
- ESM and exported TypeScript contracts; the wire engine remains private.
Guide · Trust and cryptography · Channels and files · Comparison with ssh2
The private protocol derives from ssh2 1.17.0. See LICENSE, SSH-TYPES-LICENSE, NODE-SSH-LICENSE, BCRYPT-LICENSE and PROVENANCE.json.
