modernssh
API reference

Transport and protocol types

Exact declarations for 40 package-root exports. Private and protected class members are omitted.

AlgorithmListChanges

Interface. Declared in src/AlgorithmOptions.ts.

export interface AlgorithmListChanges {
    append?: AlgorithmMatcher | readonly AlgorithmMatcher[];
    prepend?: AlgorithmMatcher | readonly AlgorithmMatcher[];
    remove?: AlgorithmMatcher | readonly AlgorithmMatcher[];
}

AlgorithmMatcher

Type. Declared in src/AlgorithmOptions.ts.

export type AlgorithmMatcher = string | RegExp;

ChannelOpenError

Class. Declared in src/packets/ChannelOpenFailure.ts.

export declare class ChannelOpenError extends Error {
    readonly name = "ChannelOpenError";
    readonly reasonCode: number;
    readonly reason_code: number;
    readonly languageTag: string;
    constructor(reasonCode: number, message: string, languageTag?: string);
    getOpenFailurePacket(recipientChannelId: number): ChannelOpenFailure;
}

ChannelOpenFailureReasonCodes

Enum. Declared in src/packets/ChannelOpenFailure.ts.

export declare enum ChannelOpenFailureReasonCodes {
    SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1,
    SSH_OPEN_CONNECT_FAILED = 2,
    SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3,
    SSH_OPEN_RESOURCE_SHORTAGE = 4
}

ClientAlgorithmList

Type. Declared in src/AlgorithmOptions.ts.

export type ClientAlgorithmList = readonly string[] | AlgorithmListChanges;

ClientAlgorithmOptions

Interface. Declared in src/AlgorithmOptions.ts.

export interface ClientAlgorithmOptions {
    kex?: ClientAlgorithmList;
    serverHostKey?: ClientAlgorithmList;
    cipher?: ClientAlgorithmList;
    hmac?: ClientAlgorithmList;
    compress?: ClientAlgorithmList;
}

DELAY_COMPRESSION_EXTENSION

Constant. Declared in src/DelayCompression.ts.

export declare const DELAY_COMPRESSION_EXTENSION = "delay-compression";

DelayCompressionAlgorithm

Type. Declared in src/DelayCompression.ts.

export type DelayCompressionAlgorithm = "none" | "zlib";

DelayCompressionConfiguration

Type. Declared in src/DelayCompression.ts.

export type DelayCompressionConfiguration = boolean | DelayCompressionOptions;

delayCompressionExtension

Function. Declared in src/DelayCompression.ts.

export declare function delayCompressionExtension(offers: DelayCompressionOptions): SSHExtension;

DelayCompressionOptions

Interface. Declared in src/DelayCompression.ts.

export interface DelayCompressionOptions {
    readonly clientToServer: readonly DelayCompressionAlgorithm[];
    readonly serverToClient: readonly DelayCompressionAlgorithm[];
}

DisconnectError

Class. Declared in src/packets/Disconnect.ts.

export declare class DisconnectError extends Error {
    name: string;
    readonly reason_code: number;
    readonly languageTag: string;
    constructor(reason_code: number, message: string, languageTag?: string);
}

DisconnectReason

Enum. Declared in src/packets/Disconnect.ts.

export declare enum DisconnectReason {
    SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1,
    SSH_DISCONNECT_PROTOCOL_ERROR = 2,
    SSH_DISCONNECT_KEY_EXCHANGE_FAILED = 3,
    SSH_DISCONNECT_RESERVED = 4,
    SSH_DISCONNECT_MAC_ERROR = 5,
    SSH_DISCONNECT_COMPRESSION_ERROR = 6,
    SSH_DISCONNECT_SERVICE_NOT_AVAILABLE = 7,
    SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8,
    SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9,
    SSH_DISCONNECT_CONNECTION_LOST = 10,
    SSH_DISCONNECT_BY_APPLICATION = 11,
    SSH_DISCONNECT_TOO_MANY_CONNECTIONS = 12,
    SSH_DISCONNECT_AUTH_CANCELLED_BY_USER = 13,
    SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14,
    SSH_DISCONNECT_ILLEGAL_USER_NAME = 15
}

ELEVATION_EXTENSION

Constant. Declared in src/Elevation.ts.

export declare const ELEVATION_EXTENSION = "elevation";

ElevationPreference

Type. Declared in src/Elevation.ts.

export type ElevationPreference = false | "default" | "elevated" | "unelevated";

ElevationRequest

Type. Declared in src/Elevation.ts.

export type ElevationRequest = Exclude<ElevationPreference, false>;

GLOBAL_REQUESTS_OK_EXTENSION

Constant. Declared in src/GlobalRequests.ts.

export declare const GLOBAL_REQUESTS_OK_EXTENSION = "global-requests-ok";

GSSAPIErrorStatus

Interface. Declared in src/packets/UserAuthGSSAPI.ts. Package export alias of UserAuthGSSAPIErrorData.

export interface UserAuthGSSAPIErrorData {
    majorStatus: number;
    minorStatus: number;
    message: string;
    languageTag: string;
}

GSSAPIKeyExchangeErrorStatus

Interface. Declared in src/packets/KexGSSAPI.ts. Package export alias of KexGSSAPIErrorData.

export interface KexGSSAPIErrorData {
    majorStatus: number;
    minorStatus: number;
    message: string;
    languageTag: string;
}

MAX_IDENTIFICATION_LENGTH

Constant. Declared in src/ProtocolVersionExchange.ts.

export declare const MAX_IDENTIFICATION_LENGTH = 255;

MAXIMUM_CHANNEL_WINDOW_SIZE

Constant. Declared in src/constants.ts.

export declare const MAXIMUM_CHANNEL_WINDOW_SIZE: number;

NegotiatedAlgorithms

Interface. Declared in src/AlgorithmOptions.ts.

export interface NegotiatedAlgorithms {
    kex: string;
    srvHostKey: string;
    cs: NegotiatedDirectionAlgorithms;
    sc: NegotiatedDirectionAlgorithms;
}

NegotiatedDirectionAlgorithms

Interface. Declared in src/AlgorithmOptions.ts.

export interface NegotiatedDirectionAlgorithms {
    cipher: string;
    mac: string;
    compress: string;
    lang: string;
}

NO_FLOW_CONTROL_EXTENSION

Constant. Declared in src/NoFlowControl.ts.

export declare const NO_FLOW_CONTROL_EXTENSION = "no-flow-control";

NoFlowControlPreference

Type. Declared in src/NoFlowControl.ts.

export type NoFlowControlPreference = false | "preferred" | "supported";

OPENSSH_INFO_SIGNAL

Constant. Declared in src/utils/Signal.ts.

/** OpenSSH extension that requests SIGINFO on BSD-derived systems. */
export declare const OPENSSH_INFO_SIGNAL = "INFO@openssh.com";

OpenSSHPrivateKeyCipher

Type. Declared in src/utils/OpenSSHPrivateKeyCipher.ts.

export type OpenSSHPrivateKeyCipher = "3des-cbc" | "aes128-cbc" | "aes192-cbc" | "aes256-cbc" | "aes128-ctr" | "aes192-ctr" | "aes256-ctr" | "aes128-gcm@openssh.com" | "aes256-gcm@openssh.com" | "chacha20-poly1305@openssh.com";

OpenSSHPrivateKeyEncryptionOptions

Interface. Declared in src/utils/OpenSSHPrivateKeyCipher.ts.

export interface OpenSSHPrivateKeyEncryptionOptions {
    passphrase: string | Buffer;
    cipher?: OpenSSHPrivateKeyCipher;
    /** bcrypt_pbkdf rounds; defaults to 16. */
    rounds?: number;
}

PeerDisconnectError

Class. Declared in src/packets/Disconnect.ts.

export declare class PeerDisconnectError extends Error {
    readonly disconnect: Readonly<PeerDisconnectInfo>;
    readonly name = "PeerDisconnectError";
    readonly reasonCode: number;
    readonly languageTag: string;
    constructor(disconnect: Readonly<PeerDisconnectInfo>);
}

PeerDisconnectInfo

Interface. Declared in src/packets/Disconnect.ts.

export interface PeerDisconnectInfo {
    readonly reasonCode: number;
    readonly description: string;
    readonly languageTag: string;
}

ProtocolDebugMessage

Interface. Declared in src/packets/Debug.ts.

export interface ProtocolDebugMessage {
    alwaysDisplay: boolean;
    message: string;
    languageTag: string;
}

ProtocolPacketMetadata

Interface. Declared in src/packet.ts.

export interface ProtocolPacketMetadata {
    readonly sequenceNumber: number;
    readonly type: number;
    readonly name?: PacketName;
}

ProtocolVersionExchange

Class. Declared in src/ProtocolVersionExchange.ts.

export default class ProtocolVersionExchange {
    readonly protocol_version: string;
    readonly protocol_software: string;
    readonly comments: string | undefined;
    constructor(protocol_version: string, protocol_software: string, comments?: string | undefined);
    static parse(raw: string | Buffer): ProtocolVersionExchange;
    /** Builds an SSH 2.0 identification from a software identifier and optional comment. */
    static fromIdent(ident: string | Buffer): ProtocolVersionExchange;
    static readonly defaultValue: ProtocolVersionExchange;
    toString(): string;
}

ServerAlgorithmOptions

Interface. Declared in src/AlgorithmOptions.ts.

export interface ServerAlgorithmOptions {
    kex?: readonly string[];
    serverHostKey?: readonly string[];
    cipher?: readonly string[];
    hmac?: readonly string[];
    compress?: readonly string[];
}

SocketState

Enum. Declared in src/constants.ts.

export declare enum SocketState {
    Connecting = 0,
    Connected = 1,
    Closed = 2,
    Disconnected = 3
}

SSHAuthenticationMethods

Enum. Declared in src/constants.ts.

export declare enum SSHAuthenticationMethods {
    None = "none",
    PublicKey = "publickey",
    Hostbased = "hostbased",
    Password = "password",
    KeyboardInteractive = "keyboard-interactive",
    GSSAPIWithMIC = "gssapi-with-mic",
    GSSAPIKeyExchange = "gssapi-keyex",
    HostboundPublicKey = "publickey-hostbound-v00@openssh.com"
}

SSHExtendedDataTypes

Enum. Declared in src/constants.ts.

export declare enum SSHExtendedDataTypes {
    SSH_EXTENDED_DATA_STDERR = 1
}

SSHExtension

Interface. Declared in src/packets/ExtInfo.ts.

export interface SSHExtension {
    readonly name: string;
    readonly value: Buffer;
}

SSHServiceNames

Enum. Declared in src/constants.ts.

export declare enum SSHServiceNames {
    UserAuth = "ssh-userauth",
    Connection = "ssh-connection"
}

UserAuthPrompt

Interface. Declared in src/packets/UserAuthInfoRequest.ts.

export interface UserAuthPrompt {
    prompt: string;
    echo: boolean;
}