Skip to content

API Reference

All operations return a result namespace unless noted:

Field Meaning
rc 0 success; nonzero (usually ¯1) failure
msg '' on success, otherwise the reason
Data operation payload (see each method)
Host Port Username connection identification
Elapsed milliseconds (set by Connect)

Expected failures (bad credentials, missing files, refused connections) are reported via rc/msg, not signalled — unless Debug bit 1 is set, which disables the internal trapping for debugging.

Shared methods

SSHClient.Version

Returns ('SSHClient' version date).

SSHClient.New args

Creates an instance from the same arguments as the constructor (positional vector or namespace). On failure returns an error result namespace instead of signalling.

SSHClient.Do args

Create → connect → exec → close in one call; returns the Exec result.

SSHClient.Do Host Cmd                       ⍝ port 22
SSHClient.Do Host Username Password Cmd     ⍝ port 22
SSHClient.Do ns                             ⍝ ns: connection fields + Cmd

SSHClient.GetEnv name

Returns the value of an environment variable ('' if unset).

Constructors

⎕NEW SSHClient                          ⍝ defaults; set fields, then Connect
⎕NEW SSHClient (Host [Port [User [Password]]])
⎕NEW SSHClient ns                       ⍝ namespace of field settings

Instance methods

Connect

Opens TCP, performs the SSH-2 handshake (key exchange, host-key signature + known_hosts verification), activates encryption, and authenticates. Data is unused; Elapsed is the handshake time in ms. On failure the connection is fully torn down; the instance may Connect again.

Exec cmd

Runs cmd on the remote host over a session channel. Data is the complete stdout — UTF-8 decoded when valid, byte-preserving characters otherwise. The result additionally carries Stderr (standard error, same decoding rules), ExitStatus (the command's exit code, ¯1 if not reported), and ExitSignal (signal name if the command was killed). rc reflects the SSH exchange, not the command's exit code (details).

GetFile (remote [local])

SFTP download. local defaults to the remote basename in the current directory. Data is the local path written. Binary-exact.

PutFile (local [remote])

SFTP upload (create/truncate). remote defaults to the local basename in the remote user's home. Data is the remote path.

ListDir path

SFTP directory listing. Data is a vector of namespaces with name, longname, size, uid, gid, permissions, atime, mtime.

Stat path

SFTP attributes. Data is a namespace with size, uid, gid, permissions, atime, mtime (0 when the server omits a field).

Close

Sends SSH_MSG_DISCONNECT, closes the socket, and resets all per-connection state. Always returns rc 0; safe to call repeatedly.

Config

Returns a two-column matrix of public field names and current values. Note it includes Password.

Init

Explicitly initialises Conga (otherwise done lazily by Connect); returns (rc msg).