---
product: Chilkat
product_version: 11.7.0
language: js
language_label: JavaScript
class: Ssh
license: bundle
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/jsSshRef.html
---
# Chilkat Ssh — JavaScript — v11.7.0

> Chilkat 11.7.0 · language=js · class=Ssh
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Ssh.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/guide.md`.

## Purpose

**Connect to SSH servers, authenticate, run commands, open channels, and manage secure sessions.**

`Chilkat.Ssh` is Chilkat's primary SSH client class for applications that need secure remote command execution, shell sessions, channel-based communication, port forwarding, and detailed control over SSH transport behavior. It supports password and public-key authentication, keyboard-interactive authentication, stdout and stderr handling, proxies, host key inspection, algorithm selection, connection reuse, and detailed diagnostics for authentication, transport, channel, and disconnect issues.

**SSH connection setup**

Connect to SSH servers with configurable timeouts, host key handling, proxy settings, preferred IP behavior, and detailed connection logging.

**Authentication options**

Authenticate with passwords, private keys, combined password/key workflows, or keyboard-interactive authentication when required by the server.

**Remote commands**

Execute commands on the server, read stdout and stderr, inspect exit status, and manage command channels.

**Shell sessions**

Open interactive shell channels for command-line sessions that require ongoing input and output rather than a single command result.

**Port forwarding**

Open SSH channels for direct TCP/IP forwarding scenarios, such as connecting securely through an SSH server to another host and port.

**Algorithm and diagnostics**

Control allowed SSH algorithms and use detailed error text, session information, and logs to troubleshoot negotiation or server behavior.

**Common pattern:** Connect to the SSH server, authenticate, open a command, shell, or forwarding channel, read the channel output until complete, close the channel, and then disconnect. Use algorithm controls and diagnostics when working with strict servers, legacy systems, or security-policy requirements.

For an extended overview, see [Ssh Class Overview](https://www.chilkatsoft.com/ssh_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

Note: This is intended for running within a [Chilkat.Js embedded JavaScript engine](https://www.chilkatsoft.com/chilkat_javascript_engine.asp).

```
var obj = new CkSsh();
```

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in JavaScript.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `DebugLogFilePath` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `LastErrorHtml` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `LastErrorText` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `LastErrorXml` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `LastMethodSuccess` | read/write | Indicates the success or failure of the most recent method call: `true` means success, `false` means failure. |
| `VerboseLogging` | `VerboseLogging` | read/write | If set to `true`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `Version` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `AbortCurrent` | property, read/write | `AbortCurrent` |
| `AuthFailReason` | property, read-only | `AuthFailReason` |
| `CaretControl` | property, read/write | `CaretControl` |
| `ChannelOpenFailCode` | property, read-only | `ChannelOpenFailCode` |
| `ChannelOpenFailReason` | property, read-only | `ChannelOpenFailReason` |
| `ClientIdentifier` | property, read/write | `ClientIdentifier` |
| `ClientIpAddress` | property, read/write | `ClientIpAddress` |
| `ClientPort` | property, read/write | `ClientPort` |
| `ConnectTimeoutMs` | property, read/write | `ConnectTimeoutMs` |
| `DisconnectCode` | property, read-only | `DisconnectCode` |
| `DisconnectReason` | property, read-only | `DisconnectReason` |
| `EnableCompression` | property, read/write | `EnableCompression` |
| `EnableSecrets` | property, read/write | `EnableSecrets` |
| `ForceCipher` | property, read/write | `ForceCipher` |
| `HostKeyAlg` | property, read/write | `HostKeyAlg` |
| `HostKeyFingerprint` | property, read-only | `HostKeyFingerprint` |
| `HttpProxyAuthMethod` | property, read/write | `HttpProxyAuthMethod` |
| `HttpProxyDomain` | property, read/write | `HttpProxyDomain` |
| `HttpProxyHostname` | property, read/write | `HttpProxyHostname` |
| `HttpProxyPassword` | property, read/write | `HttpProxyPassword` |
| `HttpProxyPort` | property, read/write | `HttpProxyPort` |
| `HttpProxyUsername` | property, read/write | `HttpProxyUsername` |
| `IdleTimeoutMs` | property, read/write | `IdleTimeoutMs` |
| `IsConnected` | property, read-only | `IsConnected` |
| `KeepSessionLog` | property, read/write | `KeepSessionLog` |
| `MaxPacketSize` | property, read/write | `MaxPacketSize` |
| `NumOpenChannels` | property, read-only | `NumOpenChannels` |
| `PasswordChangeRequested` | property, read-only | `PasswordChangeRequested` |
| `PreferIpv6` | property, read/write | `PreferIpv6` |
| `ReadTimeoutMs` | property, read/write | `ReadTimeoutMs` |
| `ReqExecCharset` | property, read/write | `ReqExecCharset` |
| `ServerIdentifier` | property, read-only | `ServerIdentifier` |
| `SessionLog` | property, read-only | `SessionLog` |
| `SocksHostname` | property, read/write | `SocksHostname` |
| `SocksPassword` | property, read/write | `SocksPassword` |
| `SocksPort` | property, read/write | `SocksPort` |
| `SocksUsername` | property, read/write | `SocksUsername` |
| `SocksVersion` | property, read/write | `SocksVersion` |
| `SoRcvBuf` | property, read/write | `SoRcvBuf` |
| `SoSndBuf` | property, read/write | `SoSndBuf` |
| `StderrToStdout` | property, read/write | `StderrToStdout` |
| `StripColorCodes` | property, read/write | `StripColorCodes` |
| `TcpNoDelay` | property, read/write | `TcpNoDelay` |
| `UncommonOptions` | property, read/write | `UncommonOptions` |
| `UserAuthBanner` | property, read/write | `UserAuthBanner` |
| `AuthenticatePk` | method | `var success = AuthenticatePk(username, privateKey);` |
| `AuthenticatePw` | method | `var success = AuthenticatePw(login, password);` |
| `AuthenticatePwPk` | method | `var success = AuthenticatePwPk(username, password, privateKey);` |
| `AuthenticateSecPw` | method | `var success = AuthenticateSecPw(login, password);` |
| `AuthenticateSecPwPk` | method | `var success = AuthenticateSecPwPk(username, password, privateKey);` |
| `ChannelIsOpen` | method | `var boolVal = ChannelIsOpen(channelNum);` |
| `ChannelPoll` | method | `var intVal = ChannelPoll(channelNum, pollTimeoutMs);` |
| `ChannelRead` | method | `var intVal = ChannelRead(channelNum);` |
| `ChannelReadAndPoll` | method | `var intVal = ChannelReadAndPoll(channelNum, pollTimeoutMs);` |
| `ChannelReadAndPoll2` | method | `var intVal = ChannelReadAndPoll2(channelNum, pollTimeoutMs, maxNumBytes);` |
| `ChannelReceivedClose` | method | `var boolVal = ChannelReceivedClose(channelNum);` |
| `ChannelReceivedEof` | method | `var boolVal = ChannelReceivedEof(channelNum);` |
| `ChannelReceivedExitStatus` | method | `var boolVal = ChannelReceivedExitStatus(channelNum);` |
| `ChannelReceiveToClose` | method | `var success = ChannelReceiveToClose(channelNum);` |
| `ChannelReceiveUntilMatch` | method | `var success = ChannelReceiveUntilMatch(channelNum, matchPattern, charset, caseSensitive);` |
| `ChannelReceiveUntilMatchN` | method | `var success = ChannelReceiveUntilMatchN(channelNum, matchPatterns, charset, caseSensitive);` |
| `ChannelRelease` | method | `ChannelRelease(channelNum);` |
| `ChannelSendClose` | method | `var success = ChannelSendClose(channelNum);` |
| `ChannelSendEof` | method | `var success = ChannelSendEof(channelNum);` |
| `ChannelSendString` | method | `var success = ChannelSendString(channelNum, textData, charset);` |
| `CheckConnection` | method | `var boolVal = CheckConnection();` |
| `ClearTtyModes` | method | `ClearTtyModes();` |
| `Connect` | method | `var success = Connect(domainName, port);` |
| `ConnectThroughSsh` | method | `var success = ConnectThroughSsh(ssh, hostname, port);` |
| `ContinueKeyboardAuth` | method | `var strVal = ContinueKeyboardAuth(response);` |
| `Disconnect` | method | `Disconnect();` |
| `GetAuthMethods` | method | `var strVal = GetAuthMethods();` |
| `GetChannelExitStatus` | method | `var intVal = GetChannelExitStatus(channelNum);` |
| `GetChannelNumber` | method | `var intVal = GetChannelNumber(index);` |
| `GetChannelType` | method | `var strVal = GetChannelType(index);` |
| `GetHostKeyFP` | method | `var strVal = GetHostKeyFP(hashAlg, includeKeyType, includeHashName);` |
| `GetLastJsonData` | method | `GetLastJsonData(json);` |
| `GetReceivedBd` | method | `var success = GetReceivedBd(channelNum, bd);` |
| `GetReceivedNumBytes` | method | `var intVal = GetReceivedNumBytes(channelNum);` |
| `GetReceivedSb` | method | `var success = GetReceivedSb(channelNum, charset, sb);` |
| `GetReceivedStderrText` | method | `var strVal = GetReceivedStderrText(channelNum, charset);` |
| `GetReceivedText` | method | `var strVal = GetReceivedText(channelNum, charset);` |
| `GetReceivedTextS` | method | `var strVal = GetReceivedTextS(channelNum, substr, charset);` |
| `OpenCustomChannel` | method | `var intVal = OpenCustomChannel(channelType);` |
| `OpenDirectTcpIpChannel` | method | `var intVal = OpenDirectTcpIpChannel(targetHostname, targetPort);` |
| `OpenSessionChannel` | method | `var intVal = OpenSessionChannel();` |
| `PeekReceivedText` | method | `var strVal = PeekReceivedText(channelNum, charset);` |
| `QuickCmdCheck` | method | `var intVal = QuickCmdCheck(pollTimeoutMs);` |
| `QuickCmdSend` | method | `var intVal = QuickCmdSend(command);` |
| `QuickCommand` | method | `var strVal = QuickCommand(command, charset);` |
| `QuickShell` | method | `var intVal = QuickShell();` |
| `ReKey` | method | `var success = ReKey();` |
| `SendIgnore` | method | `var success = SendIgnore();` |
| `SendReqExec` | method | `var success = SendReqExec(channelNum, commandLine);` |
| `SendReqPty` | method | `var success = SendReqPty(channelNum, termType, widthInChars, heightInChars, widthInPixels, heightInPixels);` |
| `SendReqSetEnv` | method | `var success = SendReqSetEnv(channelNum, name, value);` |
| `SendReqShell` | method | `var success = SendReqShell(channelNum);` |
| `SendReqSignal` | method | `var success = SendReqSignal(channelNum, signalName);` |
| `SendReqSubsystem` | method | `var success = SendReqSubsystem(channelNum, subsystemName);` |
| `SendReqWindowChange` | method | `var success = SendReqWindowChange(channelNum, widthInChars, heightInRows, pixWidth, pixHeight);` |
| `SendReqX11Forwarding` | method | `var success = SendReqX11Forwarding(channelNum, singleConnection, authProt, authCookie, screenNum);` |
| `SendReqXonXoff` | method | `var success = SendReqXonXoff(channelNum, clientCanDo);` |
| `SetAllowedAlgorithms` | method | `var success = SetAllowedAlgorithms(json);` |
| `SetTtyMode` | method | `var success = SetTtyMode(ttyName, ttyValue);` |
| `StartKeyboardAuth` | method | `var strVal = StartKeyboardAuth(login);` |
| `WaitForChannelMessage` | method | `var intVal = WaitForChannelMessage(pollTimeoutMs);` |

## Properties

### Ssh.AbortCurrent

`Chilkat 11.7.0 · js · Ssh · AbortCurrent · property · read/write · since 9.5.0.58`

```javascript
AbortCurrent
```

· `boolean`

Set to `true` to request that the currently running Chilkat operation abort. This applies to synchronous and asynchronous methods that may block on network or lengthy processing.

A synchronous call can be interrupted by setting this property from another thread. When the abort is observed, the current method returns failure, but the SSH connection and channel are not automatically closed. Bytes already buffered remain available, the remote process can continue running, and a later receive call can continue on the same channel. The same object and connection can also be used to open new channels afterward.

An aborted receive does not set `DisconnectCode` or `DisconnectReason`, and object-level configuration settings remain unchanged. An aborted `Connect` leaves the object disconnected but reusable for a later connection attempt.

When the abort is observed, Chilkat resets the property to `false`. If no operation is running, it is reset when the next method begins.

### Ssh.AuthFailReason

`Chilkat 11.7.0 · js · Ssh · AuthFailReason · property · read-only · since 9.5.0.52`

```javascript
AuthFailReason
```

· `int`, `read-only`

Contains the result code from the most recent call to an SSH authentication method, including `AuthenticatePw`, `AuthenticatePk`, `AuthenticatePwPk`, and their `SecureString` variants. The initial value is `0`, and a successful authentication resets it to `0`. A failed attempt sets one of the following values.

| Value | Meaning |
| :--- | :--- |
| `1` | Transport failure. The connection is unavailable, communication was lost, or a read operation failed or timed out. Calling an authentication method before `Connect` also produces this value. |
| `2` | Invalid key for public-key authentication. For example, the `SshKey` is empty, public-only, malformed, unsupported, or otherwise unsuitable. |
| `3` | No mutually supported authentication method was available. |
| `4` | SSH authentication protocol error. An unexpected or invalid message was received. |
| `5` | The password or private key was rejected by the server. |
| `6` | The SSH session is already authenticated. |
| `7` | The server requires a password change. See `PasswordChangeRequested`. |

This property is not cleared by unrelated operations such as `SendIgnore` or `Disconnect`. Read it immediately after an authentication method returns. If the server closes the connection because of an authentication-attempt limit, the result may be `1`; inspect `DisconnectCode`, `DisconnectReason`, and `LastErrorText`.

### Ssh.CaretControl

`Chilkat 11.7.0 · js · Ssh · CaretControl · property · read/write · since 9.5.0.49`

```javascript
CaretControl
```

· `boolean`

Controls whether recognized caret notation is converted to ASCII control characters in strings passed to `SendReqExec` and `ChannelSendString`. The default is `false`.

When set to `true`, recognized uppercase sequences such as `^C`, `^M`, `^?`, and `^^` are translated before the text is sent. An unrecognized sequence, such as lowercase `^a`, is sent literally.

```
Caret  Dec  Hex  Name  Description
^@       0   00   NUL   Null
^A       1   01   SOH   Start of Heading
^B       2   02   STX   Start of Text
^C       3   03   ETX   End of Text
^D       4   04   EOT   End of Transmission
^E       5   05   ENQ   Enquiry
^F       6   06   ACK   Acknowledge
^G       7   07   BEL   Bell
^H       8   08   BS    Backspace
^I       9   09   HT    Horizontal Tab
^J      10   0A   LF    Line Feed
^K      11   0B   VT    Vertical Tab
^L      12   0C   FF    Form Feed
^M      13   0D   CR    Carriage Return
^N      14   0E   SO    Shift Out
^O      15   0F   SI    Shift In
^P      16   10   DLE   Data Link Escape
^Q      17   11   DC1   Device Control One (XON)
^R      18   12   DC2   Device Control Two
^S      19   13   DC3   Device Control Three (XOFF)
^T      20   14   DC4   Device Control Four
^U      21   15   NAK   Negative Acknowledge
^V      22   16   SYN   Synchronous Idle
^W      23   17   ETB   End of Transmission Block
^X      24   18   CAN   Cancel
^Y      25   19   EM    End of Medium
^Z      26   1A   SUB   Substitute
^[      27   1B   ESC   Escape
^\      28   1C   FS    File Separator
^]      29   1D   GS    Group Separator
^^      30   1E   RS    Record Separator
^_      31   1F   US    Unit Separator
^?     127   7F   DEL   Delete
```

### Ssh.ChannelOpenFailCode

`Chilkat 11.7.0 · js · Ssh · ChannelOpenFailCode · property · read-only`

```javascript
ChannelOpenFailCode
```

· `int`, `read-only`

Contains the SSH channel-open failure code when the server rejects a request to open a channel. The values are defined by RFC 4254.

| Code | Symbolic name |
| :--- | :--- |
| `1` | `SSH_OPEN_ADMINISTRATIVELY_PROHIBITED` |
| `2` | `SSH_OPEN_CONNECT_FAILED` |
| `3` | `SSH_OPEN_UNKNOWN_CHANNEL_TYPE` |
| `4` | `SSH_OPEN_RESOURCE_SHORTAGE` |

The initial value is `0`. A local failure, such as attempting to open a channel before connecting, can also leave this property at `0` because no SSH channel-open failure message was received. Read this property immediately after a channel-open method returns `-1`.

### Ssh.ChannelOpenFailReason

`Chilkat 11.7.0 · js · Ssh · ChannelOpenFailReason · property · read-only`

```javascript
ChannelOpenFailReason
```

· `string`, `read-only`

Contains the descriptive text associated with `ChannelOpenFailCode` when the server rejects a channel-open request. The text is supplied by the server and may be empty or generic. The initial value is an empty string.

A rejected channel-open request normally leaves the underlying SSH connection open. Local failures that occur before a request reaches the server may leave both this property and `ChannelOpenFailCode` unchanged.

### Ssh.ClientIdentifier

`Chilkat 11.7.0 · js · Ssh · ClientIdentifier · property · read/write`

```javascript
ClientIdentifier
```

· `string`

Specifies the SSH client-identification string sent when a connection is established. The default is `SSH-2.0-Chilkat_` followed by the Chilkat version, for example `SSH-2.0-Chilkat_11.6.0`.

The value should begin with `SSH-2.0-`. A server may disconnect if the identification string is not valid.

### Ssh.ClientIpAddress

`Chilkat 11.7.0 · js · Ssh · ClientIpAddress · property · read/write`

```javascript
ClientIpAddress
```

· `string`

**This property is normally left unset.** Set it only when the computer has multiple network interfaces or multiple local IP addresses and the application needs to use a specific one.

The value may be a numeric IPv4 or IPv6 address. Do not specify a domain name. When this property is empty, Chilkat and the operating system automatically select the appropriate local address.

The specified address must be available on the local computer and must be compatible with the address family used for the connection. If the address is invalid or unavailable, the connection fails.

This setting applies to all connection paths, including direct SSH connections, HTTP and SOCKS proxy connections, `ConnectThroughSsh`, and multi-hop SSH connections.

### Ssh.ClientPort

`Chilkat 11.7.0 · js · Ssh · ClientPort · property · read/write · since 9.5.0.75`

```javascript
ClientPort
```

· `int`

**This property is normally left at its default value of `0`.** In this case, the operating system automatically chooses an unused local port from its ephemeral-port range. Applications should set a specific local port only when a remote system or network policy requires the connection to originate from that port.

When set to a nonzero value, Chilkat requests that exact local port. The connection fails if the port is already in use or is otherwise unavailable. A specifically chosen port might also be temporarily unavailable for reuse after a connection closes because of operating-system TCP connection management. These port-reuse concerns do not normally apply when this property remains `0`.

This property applies to all connection paths, including direct SSH connections, HTTP and SOCKS proxy connections, `ConnectThroughSsh`, and multi-hop SSH connections.

Starting in Chilkat v11.6.0, assigned values must be in the range `0` through `65535`. If a negative value or a value greater than `65535` is assigned, it is ignored and the existing property value remains unchanged.

### Ssh.ConnectTimeoutMs

`Chilkat 11.7.0 · js · Ssh · ConnectTimeoutMs · property · read/write`

```javascript
ConnectTimeoutMs
```

· `int`

Specifies the maximum number of milliseconds allowed for the remote endpoint to accept the TCP connection. The default is `30000` (30 seconds).

A value of `0` removes the Chilkat-imposed connect timeout; in practice, the attempt ends when the operating system reports that the connection failed. Negative values are treated as `0`.

This timeout applies whether the destination is specified by a DNS hostname or an IP address, and to direct connections and connections made through HTTP proxies, SOCKS proxies, and `ConnectThroughSsh`. For `ConnectThroughSsh`, the inner `Ssh` object’s value is used.

**Scope:** This property covers only TCP connection establishment. Proxy authentication, the SSH identification exchange, key exchange, and other server communication are controlled by `ReadTimeoutMs`.

### Ssh.DisconnectCode

`Chilkat 11.7.0 · js · Ssh · DisconnectCode · property · read-only`

```javascript
DisconnectCode
```

· `int`, `read-only`

Contains the reason code from the most recent SSH `DISCONNECT` message received from the server. The values are defined by RFC 4253.

The initial value is `0`. It also remains `0` after a normal local `Disconnect`, an ordinary TCP connection loss that did not include an SSH `DISCONNECT` message, a failed connection attempt, authentication rejection, receive timeout, receive abort, or rejected channel-open request.

When the server sends an SSH `DISCONNECT`, this property contains the server-provided code and remains available after `CheckConnection`. A subsequent call to `Connect` clears the value to `0`, whether that new attempt succeeds or fails.

| Code | Symbolic name |
| :--- | :--- |
| `1` | `SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT` |
| `2` | `SSH_DISCONNECT_PROTOCOL_ERROR` |
| `3` | `SSH_DISCONNECT_KEY_EXCHANGE_FAILED` |
| `4` | `SSH_DISCONNECT_RESERVED` |
| `5` | `SSH_DISCONNECT_MAC_ERROR` |
| `6` | `SSH_DISCONNECT_COMPRESSION_ERROR` |
| `7` | `SSH_DISCONNECT_SERVICE_NOT_AVAILABLE` |
| `8` | `SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED` |
| `9` | `SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE` |
| `10` | `SSH_DISCONNECT_CONNECTION_LOST` |
| `11` | `SSH_DISCONNECT_BY_APPLICATION` |
| `12` | `SSH_DISCONNECT_TOO_MANY_CONNECTIONS` |
| `13` | `SSH_DISCONNECT_AUTH_CANCELLED_BY_USER` |
| `14` | `SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE` |
| `15` | `SSH_DISCONNECT_ILLEGAL_USER_NAME` |

### Ssh.DisconnectReason

`Chilkat 11.7.0 · js · Ssh · DisconnectReason · property · read-only`

```javascript
DisconnectReason
```

· `string`, `read-only`

Contains the descriptive text sent with the most recent server SSH `DISCONNECT` message. See `DisconnectCode` for the corresponding RFC 4253 reason code.

The initial value is an empty string. It remains empty after a normal local `Disconnect`, an ordinary TCP connection loss without an SSH `DISCONNECT` message, a failed connection attempt, authentication rejection, receive timeout, receive abort, or rejected channel-open request.

When a server-sent SSH `DISCONNECT` is received, the text remains available after `CheckConnection`. A subsequent call to `Connect` clears it, whether the new attempt succeeds or fails. The returned string is empty rather than null when no reason is available.

### Ssh.EnableCompression

`Chilkat 11.7.0 · js · Ssh · EnableCompression · property · read/write · since 9.5.0.56`

```javascript
EnableCompression
```

· `boolean`

Controls whether SSH compression may be negotiated. The default is `true`, meaning compression is used when the server supports it.

Some older servers advertise compression but fail when it is enabled. If the server disconnects during or immediately after connection/authentication, try setting this property to `false`.

### Ssh.EnableSecrets

`Chilkat 11.7.0 · js · Ssh · EnableSecrets · property · read/write · since 11.5.0`

```javascript
EnableSecrets
```

**Full documentation for this property (same in every language):** [More Detailed Information About EnableSecrets](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/secret_specification_strings.md)

· `boolean`

Enables automatic resolution of secret specification strings from secure operating-system storage. The default is `false`.

When `true`, supported password properties and authentication methods may receive a value beginning with `!!` instead of a literal credential. Chilkat resolves the secret from Windows Credential Manager on Windows or Apple Keychain on macOS.

Secret specification format:

```
!![appName|]service[|domain]|username
```

This feature applies to `HttpProxyPassword`, `SocksPassword`, `AuthenticatePw`, and `AuthenticatePwPk`.

### Ssh.ForceCipher

`Chilkat 11.7.0 · js · Ssh · ForceCipher · property · read/write`

```javascript
ForceCipher
```

· `string`

Restricts SSH cipher negotiation to one cipher or a comma-separated preference list. Leave this property empty to let Chilkat choose the first mutually supported cipher from its normal preference order.

Supported cipher names

`chacha20-poly1305@openssh.com`

`aes128-ctr`, `aes192-ctr`, `aes256-ctr`

`aes128-cbc`, `aes192-cbc`, `aes256-cbc`

`aes128-gcm@openssh.com`, `aes256-gcm@openssh.com`

`twofish128-cbc`, `twofish256-cbc`

`blowfish-cbc`, `3des-cbc`

`arcfour128`, `arcfour256`

Cipher names must use the exact lowercase spelling shown above. If none of the specified ciphers is supported by the server, `Connect` fails.

### Ssh.HostKeyAlg

`Chilkat 11.7.0 · js · Ssh · HostKeyAlg · property · read/write`

```javascript
HostKeyAlg
```

· `string`

Specifies the preferred host-key algorithm used during SSH connection establishment. The default is `DSS`; set it to `RSA` only when required for compatibility with a particular server.

Normally this property should be left unchanged.

### Ssh.HostKeyFingerprint

`Chilkat 11.7.0 · js · Ssh · HostKeyFingerprint · property · read-only`

```javascript
HostKeyFingerprint
```

· `string`, `read-only`

Contains the connected server’s host-key fingerprint in Chilkat’s legacy MD5 format:

```
ssh-ed25519 256 c8:73:22:c7:82:aa:09:f1:1c:4e:99:8a:a0:62:a7:87
```

The value consists of the SSH host-key type, key size, and the MD5 digest represented as colon-separated hexadecimal bytes. It is empty before a successful connection and after a normal `Disconnect`, a server-sent SSH `DISCONNECT`, or a failed connection attempt.

After an abrupt TCP loss, a previously obtained fingerprint can temporarily remain even when `IsConnected` is `false`. Therefore, a nonempty value is not proof that the connection is currently usable. Check `IsConnected` before relying on per-session state.

**Server identity:** Compare the fingerprint with a value obtained from a trusted source before sending credentials. For new applications, use `GetHostKeyFP` with `SHA256`.

### Ssh.HttpProxyAuthMethod

`Chilkat 11.7.0 · js · Ssh · HttpProxyAuthMethod · property · read/write`

```javascript
HttpProxyAuthMethod
```

· `string`

Specifies the authentication method used by an HTTP proxy. Matching is case-insensitive.

| Value | Behavior |
| :--- | :--- |
| *empty* | Automatically negotiate a supported authentication method with the proxy. |
| `Basic` | Use HTTP Basic authentication. |
| `NTLM` | Use NTLM authentication. |

Basic and NTLM are the supported methods. Chilkat automatically handles a `407 Proxy Authentication Required` response and performs the required authentication exchange.

NTLMv2 is used unless NTLMv1 is explicitly selected by setting `Global.DefaultNtlmVersion` to `1`.

### Ssh.HttpProxyDomain

`Chilkat 11.7.0 · js · Ssh · HttpProxyDomain · property · read/write`

```javascript
HttpProxyDomain
```

· `string`

Specifies the optional Windows domain used for NTLM authentication with an HTTP proxy.

The value is the legacy Windows NetBIOS domain name. It is not a DNS domain name and is not the workstation name. This property is ignored unless NTLM proxy authentication is used.

### Ssh.HttpProxyHostname

`Chilkat 11.7.0 · js · Ssh · HttpProxyHostname · property · read/write`

```javascript
HttpProxyHostname
```

· `string`

Specifies the hostname or numeric IP address of an HTTP proxy.

Chilkat uses the HTTP `CONNECT` method to establish the SSH tunnel through the proxy. The TCP connection to the proxy is not itself protected by TLS for this SSH use case.

The HTTP proxy is used only when `SocksVersion` is `0`, this property is nonempty, and `HttpProxyPort` is nonzero. A configured SOCKS proxy takes precedence. These settings apply to both `Connect` and `ConnectThroughSsh`.

### Ssh.HttpProxyPassword

`Chilkat 11.7.0 · js · Ssh · HttpProxyPassword · property · read/write`

```javascript
HttpProxyPassword
```

· `string`

Specifies the password used to authenticate with an HTTP proxy.

If the proxy requires authentication and this property is empty, the connection fails.

### Ssh.HttpProxyPort

`Chilkat 11.7.0 · js · Ssh · HttpProxyPort · property · read/write`

```javascript
HttpProxyPort
```

· `int`

Specifies the HTTP proxy port.

An HTTP proxy is used only when `SocksVersion` is `0`, `HttpProxyHostname` is nonempty, and this property is nonzero. A configured SOCKS proxy takes precedence.

Common proxy ports are:

- `8080` — the most common general-purpose HTTP proxy port. It is non-privileged, so the proxy service typically does not require administrator or root privileges to bind to it.
- `3128` — commonly used by Squid and enterprise proxy infrastructure.
- `8888` — commonly used by development and debugging proxies such as Charles Proxy, Fiddler, and Burp Suite.

### Ssh.HttpProxyUsername

`Chilkat 11.7.0 · js · Ssh · HttpProxyUsername · property · read/write`

```javascript
HttpProxyUsername
```

· `string`

Specifies the username used to authenticate with an HTTP proxy.

If the proxy requires authentication and this property is empty, the connection fails.

### Ssh.IdleTimeoutMs

`Chilkat 11.7.0 · js · Ssh · IdleTimeoutMs · property · read/write`

```javascript
IdleTimeoutMs
```

· `int`

Specifies an inactivity interval, in milliseconds, for SSH receive waits that use this property. The default is `0`, meaning no inactivity limit.

This is not simply an application-output timeout. Receiving any SSH packet, including transport or channel-control traffic that contains no stdout or stderr bytes, counts as communication and restarts the interval. A remote command can therefore remain silent longer than this value without necessarily causing a timeout.

Timeout handling is method-specific. Methods having an explicit timeout argument, such as `ChannelPoll` and `WaitForChannelMessage`, use that argument for the corresponding wait. In v11.6.0 testing, `ChannelReadAndPoll` used `IdleTimeoutMs` for its initial read when `ReadTimeoutMs` was `0`.

This property governs receiving. It is not a send-progress timeout.

### Ssh.IsConnected

`Chilkat 11.7.0 · js · Ssh · IsConnected · property · read-only`

```javascript
IsConnected
```

· `boolean`, `read-only`

Returns `true` when Chilkat currently considers the SSH transport connected. It becomes `true` after `Connect` establishes the secure transport. It is `false` before connecting, after `Disconnect`, after a failed connection attempt, after a server-sent SSH `DISCONNECT`, or when socket closure is detected.

An authentication failure, channel-open rejection, receive timeout, or aborted receive does not by itself set this property to `false`. If the underlying transport remains usable, the application can retry the operation on the same connection.

Reading this property can reflect a remote close that the operating system has already reported. In testing, it became `false` before `CheckConnection` was called. However, `true` does not prove that the remote server is responsive or that a silent network failure has not occurred.

To verify that SSH traffic can still be exchanged, call `SendIgnore` and check its return value.

After abrupt transport loss or a server protocol disconnect, retained per-channel state can be stale even though this property is `false`. Treat `IsConnected = false` as authoritative for network I/O. Bytes received before the loss can remain available in a retained channel buffer.

### Ssh.KeepSessionLog

`Chilkat 11.7.0 · js · Ssh · KeepSessionLog · property · read/write`

```javascript
KeepSessionLog
```

· `boolean`

Controls whether SSH protocol traffic is accumulated in `SessionLog`. The default is `false`. This object-level setting persists across disconnects, failed operations, and subsequent connections until changed by the application.

The log for a completed session remains available after disconnect or transport loss. A later successful connection begins a new session log.

Session logging is intended for diagnostics. The log grows as a session proceeds, so disable it when no longer needed. Chilkat does not write literal authentication passwords or private-key passphrases to the session log, but diagnostic logs should still be handled as potentially sensitive.

### Ssh.MaxPacketSize

`Chilkat 11.7.0 · js · Ssh · MaxPacketSize · property · read/write`

```javascript
MaxPacketSize
```

· `int`

Specifies the maximum SSH channel packet size advertised in the `SSH_MSG_CHANNEL_OPEN` message. The default is `8192`.

For high-volume transfers, a value such as `32768` may improve performance.

### Ssh.NumOpenChannels

`Chilkat 11.7.0 · js · Ssh · NumOpenChannels · property · read-only`

```javascript
NumOpenChannels
```

· `int`, `read-only`

Returns the number of channel records in the active SSH channel collection. A channel is normally added after its open request is accepted and removed when final remote-close processing occurs.

After `Disconnect` or transport loss, this property returns `0` because former channels are no longer active or enumerable. Buffered data for a former channel can nevertheless remain retrievable by its channel number until it is released or a new connection clears it.

A channel closed locally with `ChannelSendClose` can have `ChannelIsOpen` return `false` while it is still counted until final cleanup. Conversely, a remotely closed channel can cease to be counted while its results are only temporarily retained.

**Result-lifetime warning:** Querying this property is an SSH operation that can process pending final cleanup. After `ChannelReceiveToClose` or another completion receive returns, retrieve stdout, stderr, and exit status before reading `NumOpenChannels`; otherwise the completed channel record can be discarded.

Use `GetChannelNumber` and `GetChannelType` with zero-based indexes from `0` through `NumOpenChannels - 1`. Do not assume every enumerated channel is still open for application I/O.

### Ssh.PasswordChangeRequested

`Chilkat 11.7.0 · js · Ssh · PasswordChangeRequested · property · read-only`

```javascript
PasswordChangeRequested
```

· `boolean`, `read-only`

Indicates that the server rejected password authentication because it requires the user to change the password. This property is set by `AuthenticatePw` and `AuthenticatePwPk`.

When `true`, call the authentication method again and pass both passwords in this form:

```
|oldPassword|newPassword|
```

### Ssh.PreferIpv6

`Chilkat 11.7.0 · js · Ssh · PreferIpv6 · property · read/write`

```javascript
PreferIpv6
```

· `boolean`

Controls which address family is selected when DNS resolution for a hostname returns both an IPv4 address and an IPv6 address.

- When `false` (the default), Chilkat selects the IPv4 address when one is available.
- When `true`, Chilkat selects the IPv6 address when one is available.

This property expresses a preference; it does not prohibit use of the other address family when the preferred family is unavailable.

**No address fallback:** Chilkat attempts only the first address selected from the DNS results. If that connection attempt fails, it does not automatically try another resolved address or fall back to the other address family. For example, when IPv6 is preferred and the selected IPv6 connection fails, an available IPv4 address is not subsequently tried.

### Ssh.ReadTimeoutMs

`Chilkat 11.7.0 · js · Ssh · ReadTimeoutMs · property · read/write`

```javascript
ReadTimeoutMs
```

· `int`

Specifies a receive timeout, in milliseconds, for SSH methods that use this property. The default is `0`, meaning no `ReadTimeoutMs` limit.

The exact scope is method-specific:

| Method | Observed timeout scope |
| :--- | :--- |
| `ChannelRead` | Limits the wait for channel input. |
| `ChannelReadAndPoll` | Limits the initial wait when nonzero. After the first data arrives, `pollTimeoutMs` controls the additional quiet-period wait. |
| `ChannelReceiveToClose` | Limits the receive operation while waiting for channel closure. |
| `ChannelReceiveUntilMatch` and `ChannelReceiveUntilMatchN` | Limits the wait for a matching pattern. |
| `ChannelPoll` and `WaitForChannelMessage` | Use their explicit `pollTimeoutMs` arguments instead. |

A receive timeout does not discard bytes already received. The connection and channel can remain usable, and a later receive call can continue. Always inspect and preserve buffered stdout and stderr after a timeout.

### Ssh.ReqExecCharset

`Chilkat 11.7.0 · js · Ssh · ReqExecCharset · property · read/write · since 9.5.0.47`

```javascript
ReqExecCharset
```

· `string`

Specifies the character encoding used for command text sent by `SendReqExec`, `QuickCommand`, and `QuickCmdSend`. The default is `ANSI`.

On Windows, `ANSI` uses the Windows ANSI code page returned by `GetACP`, not the OEM code page. Its exact meaning on non-Windows platforms is environment-dependent. For portable behavior, specify an explicit charset such as `utf-8` or `windows-1252`.

This property applies to the command string itself. It does not override the explicit `charset` argument passed to `ChannelSendString`.

Use a supported charset name. In v11.6.0, an unrecognized charset name was observed to fall back to UTF-8 rather than fail; applications should not rely on that fallback.

### Ssh.ServerIdentifier

`Chilkat 11.7.0 · js · Ssh · ServerIdentifier · property · read-only · since 9.5.0.71`

```javascript
ServerIdentifier
```

· `string`, `read-only`

Contains the SSH server-identification string received during connection establishment. For example:

```
SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.16
```

The initial value is an empty string. After a successful connection, the value remains available after a normal `Disconnect`, a server-sent SSH `DISCONNECT`, or an abrupt transport loss.

A subsequent failed connection attempt clears this property rather than retaining the identifier from an earlier session. A successful reconnect replaces it with the newly received identifier. The empty result is an empty string, not null.

### Ssh.SessionLog

`Chilkat 11.7.0 · js · Ssh · SessionLog · property · read-only`

```javascript
SessionLog
```

· `string`, `read-only`

Contains the in-memory SSH protocol log for the current or most recently completed successful session. Enable logging by setting `KeepSessionLog` to `true`.

The initial value is an empty string. A normal disconnect, server disconnect, or transport loss leaves the existing session log available. A later successful `Connect` starts a new session log rather than appending indefinitely to the previous session. A failed TCP connection attempt does not necessarily replace an existing session log; inspect `LastErrorText` for the failed call.

Authentication passwords and private-key passphrases are not included in the log. The log may contain server identifiers, negotiated algorithms, authentication method names, and other connection diagnostics.

This property contains log text; it is not a file path. Treat diagnostic output as potentially sensitive and avoid retaining it longer than necessary.

### Ssh.SocksHostname

`Chilkat 11.7.0 · js · Ssh · SocksHostname · property · read/write`

```javascript
SocksHostname
```

· `string`

Specifies the SOCKS proxy hostname or IPv4 address. This property is used only when `SocksVersion` is `4` or `5`. An IPv6 address cannot be used for the SOCKS proxy.

SOCKS4a is not supported. With SOCKS5, the destination hostname is sent to the proxy and resolved remotely by the proxy. IPv6 destination addresses are not supported through SOCKS5.

### Ssh.SocksPassword

`Chilkat 11.7.0 · js · Ssh · SocksPassword · property · read/write`

```javascript
SocksPassword
```

· `string`

Specifies the SOCKS5 password when username/password authentication is required. SOCKS4 does not define password authentication, so this property is ignored for SOCKS4.

SOCKS5 supports either no authentication or username/password authentication. Leave both `SocksUsername` and this property empty to request no authentication. The connection fails if the proxy requires an unsupported authentication method.

### Ssh.SocksPort

`Chilkat 11.7.0 · js · Ssh · SocksPort · property · read/write`

```javascript
SocksPort
```

· `int`

Specifies the SOCKS proxy port. The default is `1080`. This property is used only when `SocksVersion` is `4` or `5`.

### Ssh.SocksUsername

`Chilkat 11.7.0 · js · Ssh · SocksUsername · property · read/write`

```javascript
SocksUsername
```

· `string`

Specifies the SOCKS username. For SOCKS4, it is sent as the SOCKS user ID. For SOCKS5, it is used with `SocksPassword` for username/password authentication.

For SOCKS5, leave both properties empty to request no authentication.

### Ssh.SocksVersion

`Chilkat 11.7.0 · js · Ssh · SocksVersion · property · read/write`

```javascript
SocksVersion
```

· `int`

Selects whether and how a SOCKS proxy is used.

| Value | Behavior |
| :--- | :--- |
| `0` | Do not use a SOCKS proxy. This is the default. Chilkat may still use an HTTP proxy if both `HttpProxyHostname` and `HttpProxyPort` are set. |
| `4` | Connect through a SOCKS4 proxy. SOCKS4a is not supported. |
| `5` | Connect through a SOCKS5 proxy. |

**Proxy selection:** A SOCKS proxy takes precedence over an HTTP proxy. When this property is `4` or `5`, Chilkat uses the configured SOCKS proxy. When it is `0`, Chilkat uses an HTTP proxy only if `HttpProxyHostname` is nonempty and `HttpProxyPort` is nonzero. Otherwise, Chilkat connects directly to the SSH server.

Assigning a value other than `4` or `5` sets the property to `0`. These proxy settings apply to both `Connect` and `ConnectThroughSsh`.

### Ssh.SoRcvBuf

`Chilkat 11.7.0 · js · Ssh · SoRcvBuf · property · read/write`

```javascript
SoRcvBuf
```

· `int`

Specifies the socket receive-buffer size. The default is `4194304` bytes. Normally this property should remain unchanged.

When download throughput is unexpectedly low, testing a larger value may help. Values should generally be multiples of `4096`.

When a proxy is used, this setting applies to the TCP connection made to the proxy.

See also:

- [More Information about TCP performance and Buffer Sizes](http://www.cknotes.com/?p=446)

### Ssh.SoSndBuf

`Chilkat 11.7.0 · js · Ssh · SoSndBuf · property · read/write`

```javascript
SoSndBuf
```

· `int`

Specifies the socket send-buffer size. The default is `262144` bytes. Normally this property should remain unchanged.

When upload throughput is unexpectedly low, testing values such as `524288` or `1048576` may help. Values should generally be multiples of `4096`.

When a proxy is used, this setting applies to the TCP connection made to the proxy.

See also:

- [More Information about TCP performance and Buffer Sizes](http://www.cknotes.com/?p=446)

### Ssh.StderrToStdout

`Chilkat 11.7.0 · js · Ssh · StderrToStdout · property · read/write`

```javascript
StderrToStdout
```

· `boolean`

Controls whether SSH extended-data received as stderr is merged into the normal channel receive buffer. The default is `true`.

When `true`, retrieve combined stdout and stderr with `GetReceivedData`, `GetReceivedDataN`, `GetReceivedText`, or `GetReceivedTextS`. When `false`, retrieve SSH stderr separately with `GetReceivedStderr` or `GetReceivedStderrText`.

The setting is applied when each incoming stderr packet is processed. Changing it while a channel is active affects only stderr received afterward. Already separated stderr is not moved into stdout, and already merged stderr cannot later be separated.

Read-method return values count bytes in both the normal and separate stderr buffers. `GetReceivedNumBytes` counts only the normal receive buffer.

This setting also affects `QuickCommand`. When `false`, its returned string contains stdout but does not include separately received stderr.

**PTY channels:** When a pseudo-terminal is allocated, the remote terminal normally combines the process's stdout and stderr into a single PTY byte stream before SSH transports it. In that case both appear in the normal receive buffer and the stderr buffer is empty regardless of this property.

### Ssh.StripColorCodes

`Chilkat 11.7.0 · js · Ssh · StripColorCodes · property · read/write · since 9.5.0.67`

```javascript
StripColorCodes
```

· `boolean`

Controls whether terminal control sequences are removed from received text, so that the text returned is plain text. It applies to `GetReceivedText`, `GetReceivedSb` and `GetReceivedTextS`. The default is `true`.

These are removed:

- CSI sequences: `ESC[`, then optional parameter and intermediate bytes, then a final byte. These include colors and text styles (`ESC[1;31m`, `ESC[38:5:196m`), cursor movement and erasing (`ESC[H`, `ESC[K`, `ESC[2J`), mode changes such as bracketed paste (`ESC[?2004h`), and terminal queries (`ESC[6n`).
- OSC, DCS, SOS, PM and APC strings, ended by `ESC\` or BEL. For example, window titles (`ESC]0;title`), and the OSC 3008 context sequences that newer versions of systemd send around shell prompts.
- Other escape sequences, such as `ESC 7`, `ESC 8`, `ESC =`, `ESC >` and `ESC ( B`.
- The BEL, SO and SI control characters.

Line breaks (CR and LF), tabs and all other text are kept. 8-bit C1 control bytes such as `0x9B` are not removed, because those byte values also occur within UTF-8 characters. A malformed sequence loses only its ESC.

A sequence split across SSH packets is still removed: if the received text ends with an unfinished sequence, those bytes are held back and returned with the text received next. They are returned as received if the channel has received EOF or CLOSE, or the connection was lost. An unusually long sequence (over 256 bytes for CSI, or over 16384 bytes for a control string) is not held back; only its ESC is removed.

For `GetReceivedTextS`, stripping applies to both the literal substring search and the returned value; the corresponding original raw escape-sequence bytes are consumed.

It does not affect raw-byte getters, `PeekReceivedText`, pattern matching in `ChannelReceiveUntilMatch`, or the string returned by `QuickCommand`.

Only escape sequences and the control characters listed above are removed. Text that the server sends as plain characters stays: for example, the `%` and spaces that zsh writes before a prompt (its `PROMPT_SP` option).

### Ssh.TcpNoDelay

`Chilkat 11.7.0 · js · Ssh · TcpNoDelay · property · read/write`

```javascript
TcpNoDelay
```

· `boolean`

Controls the `TCP_NODELAY` setting for the underlying TCP connection. The default is `true`, which disables the Nagle algorithm and generally improves responsiveness when many small messages are exchanged.

When a proxy is used, this setting applies to the TCP connection made to the proxy.

### Ssh.UncommonOptions

`Chilkat 11.7.0 · js · Ssh · UncommonOptions · property · read/write · since 9.5.0.73`

```javascript
UncommonOptions
```

· `string`

Provides comma-separated compatibility and security options for uncommon SSH scenarios. The default is an empty string, which is appropriate for most applications.

| Keyword | Effect |
| :--- | :--- |
| `ForceUserAuthRsaSha1` | Forces `ssh-rsa`/SHA-1 for RSA user authentication. Set before connecting when a server advertises RSA-SHA2 but still requires the legacy SHA-1 user-auth signature. |
| `no-weak-mac-algs` | Removes `hmac-sha1-96`, `hmac-sha1`, `hmac-md5`, and `hmac-ripemd160` from the offered MAC algorithms. |
| `ProtectFromVpn` | On Android, bypasses an installed or active VPN. |
| `+ssh-hmac-etm` | Re-enables Encrypt-then-MAC algorithms that are disabled by default as a Terrapin mitigation. |
| `+chacha20-poly1305@openssh.com` | Re-enables `chacha20-poly1305@openssh.com`, which is disabled by default as a Terrapin mitigation. |

Set connection-negotiation options before calling `Connect`.

### Ssh.UserAuthBanner

`Chilkat 11.7.0 · js · Ssh · UserAuthBanner · property · read/write · since 9.5.0.46`

```javascript
UserAuthBanner
```

· `string`

Contains a user-authentication banner received from the server during authentication. Check this property after `StartKeyboardAuth` or another authentication attempt and display it to the user when appropriate.

This is per-authentication runtime state, not a persistent connection setting. A value assigned by the application can remain before authentication begins, including across a failed connection attempt, but an authentication attempt clears or replaces the value. In testing, both successful and rejected password authentication cleared a previously assigned value when the server sent no banner.

When no banner is available, the property returns an empty string rather than null.

## Methods

### Ssh.AuthenticatePk

`Chilkat 11.7.0 · js · Ssh · AuthenticatePk · method`

```javascript
var success = AuthenticatePk(username, privateKey);
```

· return: `boolean`; `true` for success, `false` for failure  
· username: `string`  
· privateKey: `CkSshKey`

Authenticates an active, unauthenticated SSH connection using public-key authentication. `username` identifies the server account, and `privateKey` must contain the corresponding private key. The public key must already be authorized for that account on the server.

An empty or public-only `SshKey` is rejected locally with `AuthFailReason` equal to `2`; this local validation failure does not close the SSH connection.

If the server rejects the key but keeps the connection open, the application may retry on the same connection with another private key or a different authentication method. The server may instead disconnect after an authentication-attempt limit is reached. Reconnect before retrying when `IsConnected` is `false`.

Calling this method before `Connect` fails with reason `1`. Calling it after the session is already authenticated fails with reason `6`.

After a failure, inspect `AuthFailReason`, `LastErrorText`, and, if the connection was closed, `DisconnectReason`.

Returns true for success, false for failure.

See also:

- [Beware of too much time between connect and authentication.](http://www.cknotes.com/?p=278)

### Ssh.AuthenticatePw

`Chilkat 11.7.0 · js · Ssh · AuthenticatePw · method`

```javascript
var success = AuthenticatePw(login, password);
```

· return: `boolean`; `true` for success, `false` for failure  
· login: `string`  
· password: `string`

Authenticates an active, unauthenticated SSH connection using `login` and `password`.

Call `Connect` first. Calling this method without a connection fails with `AuthFailReason` equal to `1`. Calling it after the session is already authenticated fails with reason `6`.

If authentication fails and the server keeps the SSH connection open, `IsConnected` remains `true` and the application may retry on the same connection with corrected credentials or a different authentication method. A later correct password succeeded on the same connection in testing. A server can disconnect after too many failed attempts; reconnect before retrying when `IsConnected` is `false`.

An authentication attempt clears or replaces `UserAuthBanner`. Object-level configuration settings remain unchanged.

If the server requests a password change, see `PasswordChangeRequested`.

After a failure, inspect `AuthFailReason` and `LastErrorText`. `DisconnectCode` and `DisconnectReason` remain zero and empty unless the server actually sends an SSH `DISCONNECT`.

Returns true for success, false for failure.

See also:

- [Beware of too much time between connect and authentication.](http://www.cknotes.com/?p=278)

### Ssh.AuthenticatePwPk

`Chilkat 11.7.0 · js · Ssh · AuthenticatePwPk · method`

```javascript
var success = AuthenticatePwPk(username, password, privateKey);
```

· return: `boolean`; `true` for success, `false` for failure  
· username: `string`  
· password: `string`  
· privateKey: `CkSshKey`

Authenticates with a server that requires both a password and a private key. `username` is the username, `password` is the password, and `privateKey` is the private key.

Most servers require either password or public-key authentication rather than both. After a failure, inspect `AuthFailReason` and `LastErrorText`.

Returns true for success, false for failure.

### Ssh.AuthenticateSecPw

`Chilkat 11.7.0 · js · Ssh · AuthenticateSecPw · method · since 9.5.0.71`

```javascript
var success = AuthenticateSecPw(login, password);
```

· return: `boolean`; `true` for success, `false` for failure  
· login: `CkSecureString`  
· password: `CkSecureString`

Performs the same authentication as `AuthenticatePw`, but receives the login and password in `SecureString` objects.

The connection-state, retry, timeout, and `AuthFailReason` behavior is the same as for `AuthenticatePw`.

Returns true for success, false for failure.

### Ssh.AuthenticateSecPwPk

`Chilkat 11.7.0 · js · Ssh · AuthenticateSecPwPk · method · since 9.5.0.71`

```javascript
var success = AuthenticateSecPwPk(username, password, privateKey);
```

· return: `boolean`; `true` for success, `false` for failure  
· username: `CkSecureString`  
· password: `CkSecureString`  
· privateKey: `CkSshKey`

Performs the same combined password/private-key authentication as `AuthenticatePwPk`, but receives the username and password in `SecureString` objects.

Returns true for success, false for failure.

### Ssh.ChannelIsOpen

`Chilkat 11.7.0 · js · Ssh · ChannelIsOpen · method`

```javascript
var boolVal = ChannelIsOpen(channelNum);
```

· return: `boolean`  
· channelNum: `int`

Returns `true` when `channelNum` identifies a channel that Chilkat currently considers open for application I/O; otherwise returns `false`. It returns `false` for invalid or nonexistent channel numbers, after a normal local `Disconnect`, after remote closure is processed, and immediately after `ChannelSendClose` closes the channel locally.

`NumOpenChannels` can temporarily continue counting a locally closed channel until final remote-close processing occurs.

**Connection loss:** After abrupt transport loss or a server-sent SSH `DISCONNECT`, a retained channel record can temporarily cause this method to return `true` even though `IsConnected` is `false`. Treat `IsConnected = false` as authoritative. Buffered bytes from before the loss can still be retrievable.

### Ssh.ChannelPoll

`Chilkat 11.7.0 · js · Ssh · ChannelPoll · method`

```javascript
var intVal = ChannelPoll(channelNum, pollTimeoutMs);
```

· return: `int`  
· channelNum: `int`  
· pollTimeoutMs: `int`

Polls `channelNum` for incoming SSH channel messages, waiting at most `pollTimeoutMs` milliseconds. Pass `0` for a nonblocking poll. The explicit `pollTimeoutMs` controls this wait; shorter values of `ReadTimeoutMs` or `IdleTimeoutMs` do not shorten it.

Data received is appended to the normal receive buffer or separate stderr buffer according to `StderrToStdout`.

| Return value | Meaning |
| :--- | :--- |
| `-1` | An error occurred. Inspect `LastErrorText`, `IsConnected`, and `ChannelIsOpen`. |
| `-2` | No additional applicable channel message arrived before the applicable timeout. Previously buffered stdout or stderr can still be available. |
| `0` | EOF or channel closure was processed. Buffered data can still remain and should be drained. |
| `> 0` | The total number of bytes currently buffered for the channel, counting both the normal receive buffer and a separate stderr buffer. It is not the number of bytes newly received by this call. |

The return value is not a newly received byte count. Inspect `GetReceivedNumBytes`, retrieve separate stderr when applicable, and check EOF, CLOSE, and exit-status flags. Processing a final channel message can remove a completed channel record, so drain buffered output before polling again.

### Ssh.ChannelRead

`Chilkat 11.7.0 · js · Ssh · ChannelRead · method`

```javascript
var intVal = ChannelRead(channelNum);
```

· return: `int`  
· channelNum: `int`

Reads incoming SSH channel messages for `channelNum`. A nonzero `ReadTimeoutMs` limits the wait for channel input. Received data is appended to the normal receive buffer or separate stderr buffer according to `StderrToStdout`.

| Return value | Meaning |
| :--- | :--- |
| `-1` | An error occurred. Inspect `LastErrorText`, `IsConnected`, and `ChannelIsOpen`. |
| `-2` | No additional applicable channel message arrived before the applicable timeout. Previously buffered stdout or stderr can still be available. |
| `0` | EOF or channel closure was processed. Buffered data can still remain and should be drained. |
| `> 0` | The total number of bytes currently buffered for the channel, counting both the normal receive buffer and a separate stderr buffer. It is not the number of bytes newly received by this call. |

A timeout returns `-2` rather than closing the channel. A later read can continue on the same channel.

Because all channels share one SSH transport, this method can also process and buffer packets for other open channels while waiting for `channelNum`.

### Ssh.ChannelReadAndPoll

`Chilkat 11.7.0 · js · Ssh · ChannelReadAndPoll · method`

```javascript
var intVal = ChannelReadAndPoll(channelNum, pollTimeoutMs);
```

· return: `int`  
· channelNum: `int`  
· pollTimeoutMs: `int`

Reads `channelNum` in two phases:

1. Waits for the first applicable channel message. A nonzero `ReadTimeoutMs` limits this initial wait. When `ReadTimeoutMs` is `0`, `IdleTimeoutMs` can provide the initial-read timeout.
2. After data begins arriving, continues processing until no additional data arrives for `pollTimeoutMs` milliseconds.

The second phase is governed by `pollTimeoutMs`; a shorter `ReadTimeoutMs` does not shorten that quiet-period wait.

This pattern is useful for shell commands: allow a longer wait for the first output, then stop shortly after the output stream becomes idle.

| Return value | Meaning |
| :--- | :--- |
| `-1` | An error occurred. Inspect `LastErrorText`, `IsConnected`, and `ChannelIsOpen`. |
| `-2` | No additional applicable channel message arrived before the applicable timeout. Previously buffered stdout or stderr can still be available. |
| `0` | EOF or channel closure was processed. Buffered data can still remain and should be drained. |
| `> 0` | The total number of bytes currently buffered for the channel, counting both the normal receive buffer and a separate stderr buffer. It is not the number of bytes newly received by this call. |

The method can return `0` or `-2` while bytes remain buffered. Drain the normal and stderr buffers based on their actual contents, not solely on the method return value.

### Ssh.ChannelReadAndPoll2

`Chilkat 11.7.0 · js · Ssh · ChannelReadAndPoll2 · method`

```javascript
var intVal = ChannelReadAndPoll2(channelNum, pollTimeoutMs, maxNumBytes);
```

· return: `int`  
· channelNum: `int`  
· pollTimeoutMs: `int`  
· maxNumBytes: `int`

Works like `ChannelReadAndPoll`, but also returns after newly processed data causes the total buffered channel data to reach or exceed `maxNumBytes`.

`maxNumBytes` is a return threshold, not a hard receive-buffer limit. An entire SSH packet can be buffered, so the amount returned can exceed the requested threshold. Data already buffered before the call does not by itself cause an immediate threshold return.

A value of `0` or a negative value does not impose a useful threshold. For streaming large output, use a positive threshold, drain the buffer after each call, and perform a final drain when EOF or CLOSE is observed.

| Return value | Meaning |
| :--- | :--- |
| `-1` | An error occurred. Inspect `LastErrorText`, `IsConnected`, and `ChannelIsOpen`. |
| `-2` | No additional applicable channel message arrived before the timeout. Previously buffered stdout or stderr can still be available. |
| `0` | EOF or channel closure was processed. Buffered data can still remain and should be drained. |
| `> 0` | The total number of bytes currently buffered for the channel, counting both the normal receive buffer and a separate stderr buffer. It is not the number of bytes newly received by this call. |

### Ssh.ChannelReceivedClose

`Chilkat 11.7.0 · js · Ssh · ChannelReceivedClose · method`

```javascript
var boolVal = ChannelReceivedClose(channelNum);
```

· return: `boolean`  
· channelNum: `int`

Returns `true` if an SSH `CLOSE` message has been received for `channelNum`. Remote CLOSE is distinct from EOF and closes the channel in both directions. When it is processed, `ChannelIsOpen` becomes `false` and the channel is normally removed from `NumOpenChannels`.

Returns `false` for an invalid, released, locally disconnected, or no-longer-retained channel number. A transport can be lost without receiving a channel CLOSE; check `IsConnected` separately.

Retrieve buffered output, stderr, and exit status promptly after the receive method completes and before calling `ChannelRelease`.

### Ssh.ChannelReceivedEof

`Chilkat 11.7.0 · js · Ssh · ChannelReceivedEof · method`

```javascript
var boolVal = ChannelReceivedEof(channelNum);
```

· return: `boolean`  
· channelNum: `int`

Returns `true` if an SSH `EOF` message has been received for `channelNum`. EOF means the server will send no more ordinary channel data. It does not close the channel.

The server can send EOF before it sends `CLOSE`. During that interval, this method is `true`, `ChannelReceivedClose` is `false`, and the channel can remain open and counted by `NumOpenChannels`. Exit status and CLOSE can arrive later.

Returns `false` for an invalid, released, disconnected, or no-longer-retained channel number. After transport failure, channel flags can be stale or unavailable; check `IsConnected` first.

### Ssh.ChannelReceivedExitStatus

`Chilkat 11.7.0 · js · Ssh · ChannelReceivedExitStatus · method`

```javascript
var boolVal = ChannelReceivedExitStatus(channelNum);
```

· return: `boolean`  
· channelNum: `int`

Returns `true` if the server supplied an exit-status value for `channelNum`. When `true`, call `GetChannelExitStatus`.

Exit status is independent of EOF and CLOSE. It can arrive after EOF and before or with CLOSE. The server is not required to send an exit status for every channel type or command.

Returns `false` for an invalid, released, disconnected, or no-longer-retained channel number. A connection failure does not synthesize an exit status.

Check this flag and retrieve the value immediately after the receive method completes. A later unrelated SSH operation, including channel enumeration, can finalize and remove the completed channel record.

### Ssh.ChannelReceiveToClose

`Chilkat 11.7.0 · js · Ssh · ChannelReceiveToClose · method`

```javascript
var success = ChannelReceiveToClose(channelNum);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`

Receives data on `channelNum` until the server sends and Chilkat processes channel `CLOSE`. The server can send EOF earlier; EOF alone does not complete this method.

Both normal data and stderr are processed. Stderr is merged or kept separate according to `StderrToStdout`. A nonzero `ReadTimeoutMs` limits the receive operation. `IdleTimeoutMs` is not a simple stdout/stderr inactivity timer because any SSH communication can restart it.

If the method times out or is canceled, bytes received before the failure remain buffered, the SSH connection and channel can remain open, and a later call can continue receiving on the same channel. These outcomes do not set `DisconnectCode` or `DisconnectReason`. If the SSH transport is lost, the method fails and `IsConnected` becomes `false`, but bytes received before the loss can still remain retrievable.

This method buffers all received output in memory. It successfully accumulated at least 8 MiB in testing, but no upper limit was established. For potentially large or unbounded output, use incremental reads and drain the buffers as data arrives.

**Retrieve completed-channel results immediately.** After this method returns, get stdout, stderr, and exit status before calling unrelated SSH methods or querying `NumOpenChannels`. A later SSH operation can finalize and discard the completed channel record.

A `true` return means the SSH receive operation completed. It does not mean the remote command exited successfully.

Returns true for success, false for failure.

### Ssh.ChannelReceiveUntilMatch

`Chilkat 11.7.0 · js · Ssh · ChannelReceiveUntilMatch · method`

```javascript
var success = ChannelReceiveUntilMatch(channelNum, matchPattern, charset, caseSensitive);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· matchPattern: `string`  
· charset: `string`  
· caseSensitive: `boolean`

Receives text on `channelNum` until the accumulated text matches `matchPattern`. Existing buffered text is checked before waiting for additional network data.

The supported pattern syntax consists of literal characters plus `*`, which matches zero or more characters and can span line breaks. It can appear anywhere in the pattern. The `?` wildcard and bracket character classes are not supported, and backslash does not escape a literal `*`. A pattern containing only `*` waits until at least some text has arrived rather than matching an empty buffer immediately.

`charset` specifies the character encoding, and `caseSensitive` controls comparison. The method can read beyond the matched text because an entire SSH packet may already be available.

Matching considers stderr even when `StderrToStdout` is `false`. `StripColorCodes` is not applied before matching.

A nonzero `ReadTimeoutMs` limits the wait. `IdleTimeoutMs` is not a substitute for this limit because unrelated SSH traffic can restart the inactivity interval.

**Usage notes:**

- Use distinctive literal sentinels when exact command boundaries are required.
- After success, `GetReceivedTextS` can remove and return text through a known literal terminator.
- Avoid an empty `matchPattern`; it does not define a useful boundary.

Returns true for success, false for failure.

### Ssh.ChannelReceiveUntilMatchN

`Chilkat 11.7.0 · js · Ssh · ChannelReceiveUntilMatchN · method`

```javascript
var success = ChannelReceiveUntilMatchN(channelNum, matchPatterns, charset, caseSensitive);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· matchPatterns: `CkStringArray`  
· charset: `string`  
· caseSensitive: `boolean`

Works like `ChannelReceiveUntilMatch`, but returns when any pattern in `matchPatterns` is matched. The array must contain at least one element.

The first matching content encountered in the received stream determines when the method returns; array order does not override an earlier token in the stream. Existing buffered text is checked before waiting. Empty elements are ignored, and duplicate patterns are allowed.

The method does not return the index or value of the pattern that matched, and `GetLastJsonData` does not identify it. After success, inspect the buffered text or use distinct nonoverlapping sentinels that the application can identify reliably.

The same pattern grammar, stderr behavior, and `ReadTimeoutMs` behavior described for `ChannelReceiveUntilMatch` apply.

Returns true for success, false for failure.

### Ssh.ChannelRelease

`Chilkat 11.7.0 · js · Ssh · ChannelRelease · method · since 9.5.0.44`

```javascript
ChannelRelease(channelNum);
```

· return: `undefined`  
· channelNum: `int`

Releases Chilkat’s retained local resources for `channelNum` after all required output and exit information has been retrieved. It does not send EOF or CLOSE and is not a channel-closing method.

Calling it while a channel is still protocol-open has no effect. It can also be called after `Disconnect` to discard buffered data retained for a former channel. After release, methods such as `GetReceivedNumBytes` report that the channel is unavailable.

Calling this method with an invalid channel number is a harmless no-op. Repeated calls are harmless.

Do not release a completed channel until stdout, stderr, and exit status have been retrieved. Also avoid unrelated SSH calls between completion and result retrieval because they can finalize and remove the completed channel record.

```
ChannelReceiveToClose(channelNum)
GetReceivedText(...)
GetReceivedStderrText(...)
if (ChannelReceivedExitStatus(channelNum))
    GetChannelExitStatus(channelNum)
ChannelRelease(channelNum)
```

### Ssh.ChannelSendClose

`Chilkat 11.7.0 · js · Ssh · ChannelSendClose · method`

```javascript
var success = ChannelSendClose(channelNum);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`

Sends an SSH `CLOSE` message for `channelNum` and immediately marks the channel locally closed. The method does not wait for remote EOF, remote CLOSE, or an exit status, and it does not guarantee that the remote process has terminated.

After a successful call, `ChannelIsOpen` returns `false`, but `NumOpenChannels` can continue counting the channel until final remote-close processing occurs. A repeated call can succeed while the local channel record remains; after the remote CLOSE removes the channel, another call fails because the channel no longer exists.

For normal exec completion, prefer receiving through the remote CLOSE so all output and exit information can be collected. Use this method when the application intentionally abandons or closes the channel early.

Returns true for success, false for failure.

### Ssh.ChannelSendEof

`Chilkat 11.7.0 · js · Ssh · ChannelSendEof · method`

```javascript
var success = ChannelSendEof(channelNum);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`

Sends an SSH `EOF` message on `channelNum`. This closes only the client-to-server data direction. The application may continue receiving stdout, stderr, exit status, EOF, and CLOSE from the server.

After EOF is sent, do not call `ChannelSendData` or `ChannelSendString` again for that channel. A later send call can return `true` even though the data is not delivered to the remote process. Repeated calls to `ChannelSendEof` are harmless but unnecessary.

For an exec request that reads standard input, EOF is the normal way to indicate that all input has been supplied.

Returns true for success, false for failure.

### Ssh.ChannelSendString

`Chilkat 11.7.0 · js · Ssh · ChannelSendString · method`

```javascript
var success = ChannelSendString(channelNum, textData, charset);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· textData: `string`  
· charset: `string`

Encodes `textData` using `charset`, then sends the resulting bytes on `channelNum`. No line ending or terminator is added automatically.

An empty string is valid and sends zero bytes. When `CaretControl` is `true`, recognized caret sequences are translated to control characters before sending.

On Windows, `ANSI` uses the Windows ANSI code page returned by `GetACP`, not the OEM code page. Its meaning on other platforms is environment-dependent. Use an explicit charset such as `utf-8` or `windows-1252` for portable behavior.

Use a supported charset name. In v11.6.0, an unrecognized charset name was observed to fall back to UTF-8 rather than fail; applications should not rely on that fallback.

The method handles SSH packet sizing and channel-window flow control internally. It does not expose a partial-byte count if an error occurs.

Do not call this method after `ChannelSendEof`. A successful return after EOF does not guarantee that the text was delivered.

See [Supported Charsets](https://www.chilkatsoft.com/charsets_supported_by_chilkat.asp).

Returns true for success, false for failure.

### Ssh.CheckConnection

`Chilkat 11.7.0 · js · Ssh · CheckConnection · method · since 9.5.0.46`

```javascript
var boolVal = CheckConnection();
```

· return: `boolean`

Returns `true` when the underlying SSH transport currently appears connected, and `false` when the object is unconnected, has been disconnected, a connection attempt failed, or transport loss has already been detected.

In testing, this method returned immediately and matched `IsConnected`. It should not be treated as an end-to-end SSH round trip or proof that the remote server is responsive. Use `SendIgnore` when an active SSH exchange is required.

This method does not authenticate the session. A failed authentication, receive timeout, receive abort, or rejected channel-open request can leave it returning `true` because those failures do not necessarily close the transport.

A `false` result can simply mean that no connection exists. The method does not necessarily replace `LastErrorText`, so an existing error string may describe an earlier operation.

Returns `true` if the underlying TCP socket does not currently appear to be closed, or `false` if the connection is known to be closed or invalid.

Unlike `IsConnected`, which reports the connection state already known by the `Ssh` object, this method performs an additional non-consuming check of the socket. It calls the operating system's `recv` function with `MSG_PEEK` to inspect up to one byte without removing any data from the socket's receive buffer.

**Important:** This is a local socket-state check. It does not send an SSH message, wait for an SSH response, authenticate the session, or prove that the remote SSH server is responsive. For example, it may still return `true` when the network path is silently broken but the operating system has not yet detected the failure. Use `SendIgnore` when an active SSH round trip is required.

A receive timeout, aborted operation, authentication failure, or rejected channel request does not necessarily close the socket. In those cases, `CheckConnection` may continue to return `true`.

A `false` result can simply mean that no connection exists. This method may not replace `LastErrorText` when no new socket error is generated, so the existing diagnostic text can describe an earlier operation.

### Ssh.ClearTtyModes

`Chilkat 11.7.0 · js · Ssh · ClearTtyModes · method`

```javascript
ClearTtyModes();
```

· return: `undefined`

Clears all TTY mode settings previously added with `SetTtyMode`. The next `SendReqPty` request will not include those cleared modes.

### Ssh.Connect

`Chilkat 11.7.0 · js · Ssh · Connect · method`

```javascript
var success = Connect(domainName, port);
```

· return: `boolean`; `true` for success, `false` for failure  
· domainName: `string`  
· port: `int`

Establishes an SSH connection to `domainName` on the TCP port specified by `port`. The `domainName` may be a DNS hostname or a numeric IPv4 or IPv6 address. A null or empty `domainName` is treated as a zero-length hostname and causes the call to fail.

**Proxy selection:** If `SocksVersion` is `4` or `5`, Chilkat connects through the configured SOCKS proxy. Otherwise, if `HttpProxyHostname` is nonempty and `HttpProxyPort` is nonzero, Chilkat connects through the HTTP proxy. If neither condition applies, Chilkat connects directly to the SSH server.

**Connection state after success:** A successful call means the TCP connection and secure SSH transport are established. The client and server identification strings have been exchanged, key exchange has completed, and the server host key has been received and cryptographically verified as part of the SSH key exchange. User authentication has not yet started, so every newly connected session is unauthenticated. Next call an authentication method such as `AuthenticatePw`, `AuthenticatePk`, `AuthenticatePwPk`, or `StartKeyboardAuth`.

If this method is called while the object is already connected, Chilkat first disconnects the existing session and then establishes a new connection. This occurs even when connecting again to the same server. The existing connection and active channel collection are replaced. A new connection attempt also clears retained data belonging to channels from an earlier disconnected or lost session.

The same `Ssh` object may be reused after `Disconnect`, connection refusal, connect timeout, connect abort, server protocol disconnect, or abrupt transport loss. A failed call leaves `IsConnected` equal to `false`. Every successful new connection is unauthenticated and must be authenticated again. Channel numbers are opaque and can continue increasing across reconnects; do not assume they restart at zero.

**Persistent configuration:** Representative writable settings remained unchanged across normal disconnects, failed connection attempts, authentication failures, receive timeouts and aborts, rejected channel opens, server disconnects, transport loss, and subsequent reconnects. Tested settings included connection and receive timeouts, socket settings, proxy-independent client settings, logging options, character-set and output options, compression, and uncommon options. Runtime state such as authentication, channels, disconnect diagnostics, host-key state, authentication banners, and session-log contents has a separate lifecycle.

**Typical state sequence:** disconnected → SSH transport connected → authenticated → channels open. The operations valid in each state follow the SSH protocol.

**Supported negotiation algorithms include:**

| Category | Algorithms |
| :--- | :--- |
| Host key | `ssh-ed25519`, `rsa-sha2-256`, `rsa-sha2-512`, `ecdsa-sha2-nistp256`, `ecdsa-sha2-nistp384`, `ecdsa-sha2-nistp521`, `ssh-rsa`, `ssh-dss` |
| Key exchange | `curve25519-sha256`, `curve25519-sha256@libssh.org`, NIST ECDH, DH group 1/14/16/18, and group-exchange SHA-1/SHA-256 |
| Ciphers | AES CTR/CBC/GCM, Twofish CBC, Blowfish CBC, and optionally `chacha20-poly1305@openssh.com` |
| MAC | SHA-2, SHA-1, RIPEMD-160, MD5, and optionally OpenSSH Encrypt-then-MAC variants |
| Compression | `none`, `zlib`, and `zlib@openssh.com` |

**Connection failures:** Every Internet protocol begins with a TCP connection. Firewalls, endpoint security software, network ACLs, routing, proxies, or server-side policy may block the connection before SSH negotiation begins.

Returns true for success, false for failure.

### Ssh.ConnectThroughSsh

`Chilkat 11.7.0 · js · Ssh · ConnectThroughSsh · method · since 9.5.0.55`

```javascript
var success = ConnectThroughSsh(ssh, hostname, port);
```

· return: `boolean`; `true` for success, `false` for failure  
· ssh: `CkSsh`  
· hostname: `string`  
· port: `int`

Connects to another SSH server through the already connected and authenticated `Ssh` object in `ssh`. `hostname` and `port` identify the destination host and port.

```
application  →  first SSH server  →  destination SSH server
```

After this method succeeds, authenticate separately with the destination server by calling one of its `Authenticate*` methods.

The proxy properties, `ClientIpAddress`, `ClientPort`, and socket options on the inner object apply to this connection. SOCKS takes precedence over HTTP proxy settings, using the same selection rules as `Connect`.

The inner object’s `ConnectTimeoutMs` controls the timeout for establishing this connection.

Returns true for success, false for failure.

### Ssh.ContinueKeyboardAuth

`Chilkat 11.7.0 · js · Ssh · ContinueKeyboardAuth · method · since 9.5.0.46`

```javascript
var strVal = ContinueKeyboardAuth(response);
```

· return: `string`  
· response: `string`

Continues keyboard-interactive authentication by submitting the response in `response`. For a single prompt, `response` may be the response text. When the preceding information request contains multiple prompts, supply an XML response:

```
<response>
  <response1>response to first prompt</response1>
  <response2>response to second prompt</response2>
  ...
</response>
```

The returned XML has one of three forms: authentication success, authentication failure, or another information request containing additional prompts.

```
<success>success message</success>

<error>error message</error>

<infoRequest numPrompts="N">
  <name>name</name>
  <instruction>instructions</instruction>
  <prompt1 echo="1_or_0">prompt text</prompt1>
  ...
</infoRequest>
```

Returns `null` on failure

### Ssh.Disconnect

`Chilkat 11.7.0 · js · Ssh · Disconnect · method`

```javascript
Disconnect();
```

· return: `undefined`

Closes the current SSH transport. It is harmless to call when no connection exists and may be called repeatedly.

After this method returns, `IsConnected` is `false`, `NumOpenChannels` is `0`, and former channels are no longer open or enumerated. However, bytes that were already buffered for a former channel can remain retrievable by its channel number after the disconnect. Retrieve the data and call `ChannelRelease`, or allow the next `Connect` call to clear retained old-channel data.

A local disconnect does not set `DisconnectCode` or `DisconnectReason`; they remain `0` and an empty string. `ServerIdentifier` remains available, while `HostKeyFingerprint` is cleared.

The `Ssh` object remains reusable. Writable configuration settings are not reset and remain in effect for subsequent calls to `Connect`. Every new connection begins unauthenticated.

### Ssh.GetAuthMethods

`Chilkat 11.7.0 · js · Ssh · GetAuthMethods · method · since 9.5.0.78`

```javascript
var strVal = GetAuthMethods();
```

· return: `string`

Queries a connected, unauthenticated SSH server for its advertised user-authentication methods. The result is a lowercase, comma-separated list without spaces, such as `publickey,password,keyboard-interactive`.

**Connection side effect:** Call this method after `Connect` and before authenticating. It intentionally disconnects after the query, so call `Connect` again before authenticating. Calling it after successful authentication fails and also leaves the object disconnected.

Returns `null` on failure

### Ssh.GetChannelExitStatus

`Chilkat 11.7.0 · js · Ssh · GetChannelExitStatus · method`

```javascript
var intVal = GetChannelExitStatus(channelNum);
```

· return: `int`  
· channelNum: `int`

Returns the remote process exit status received for `channelNum`. Call this method only after `ChannelReceivedExitStatus` returns `true`.

Retrieve the value immediately after the receive operation and before calling unrelated SSH methods, querying `NumOpenChannels`, or releasing the channel. After the completed channel record is removed, a returned numeric `0` is not a valid substitute for checking method success.

An exit status of `0` conventionally indicates success on Unix-like systems; nonzero meanings are determined by the remote program and operating system. A nonzero exit status is not a Chilkat API failure and does not cause `SendReqExec` or `ChannelReceiveToClose` to fail.

### Ssh.GetChannelNumber

`Chilkat 11.7.0 · js · Ssh · GetChannelNumber · method`

```javascript
var intVal = GetChannelNumber(index);
```

· return: `int`  
· index: `int`

Returns the channel number at zero-based enumeration `index` in the active channel collection. The index is an enumeration position, not a channel number. Use `NumOpenChannels` to determine the valid range from `0` through `NumOpenChannels - 1`.

Returns `-1` when `index` is negative or otherwise out of range, including index `0` when the collection is empty. Channel numbers are opaque identifiers; do not assume they start at `0`, reset after reconnect, are sequential, or are reused predictably.

The active collection can temporarily include a channel that was closed locally and is awaiting final remote-close processing. Former channels retained only for buffered-result retrieval after disconnect are not enumerated.

### Ssh.GetChannelType

`Chilkat 11.7.0 · js · Ssh · GetChannelType · method`

```javascript
var strVal = GetChannelType(index);
```

· return: `string`  
· index: `int`

Returns the type of the channel at zero-based enumeration `index` in the active channel collection. The index is an enumeration position, not a channel number. Possible values include `session`, `x11`, `forwarded-tcpip`, and `direct-tcpip`.

If `index` is negative or otherwise out of range, the string-returning method reports failure, returns null, and sets `LastMethodSuccess` to `false`. This includes index `0` when `NumOpenChannels` is `0`.

The active collection can temporarily include a channel that was closed locally but is still awaiting final remote-close processing. Former channels retained only for buffered-result retrieval after disconnect are not enumerated.

Returns `null` on failure

### Ssh.GetHostKeyFP

`Chilkat 11.7.0 · js · Ssh · GetHostKeyFP · method · since 9.5.0.92`

```javascript
var strVal = GetHostKeyFP(hashAlg, includeKeyType, includeHashName);
```

· return: `string`  
· hashAlg: `string`  
· includeKeyType: `boolean`  
· includeHashName: `boolean`

Returns the active connection’s server host-key fingerprint. `hashAlg` specifies the hash algorithm. Hash-algorithm names are case-insensitive. Common choices include `SHA256`, `SHA384`, `SHA512`, `SHA1`, `MD5`, and the supported SHA-3 algorithms.

The digest is Base64 encoded without trailing padding characters. `includeKeyType` controls whether the host-key type is included, and `includeHashName` controls whether the canonical hash name is included.

| `includeKeyType` | `includeHashName` | Example format |
| :--- | :--- | :--- |
| `true` | `true` | `ssh-ed25519 SHA256:S1GreiGjlHBf1QlPPaHs2qxor4nDYl9bhFcPRN4FwF0` |
| `true` | `false` | `ssh-ed25519 S1GreiGjlHBf1QlPPaHs2qxor4nDYl9bhFcPRN4FwF0` |
| `false` | `true` | `SHA256:S1GreiGjlHBf1QlPPaHs2qxor4nDYl9bhFcPRN4FwF0` |
| `false` | `false` | `S1GreiGjlHBf1QlPPaHs2qxor4nDYl9bhFcPRN4FwF0` |

An active SSH connection is required. The method fails when called before connecting or after disconnecting. For `MD5`, this method still returns an unpadded Base64 digest; it does not return the colon-separated hexadecimal form used by `HostKeyFingerprint`.

**Important:** If `hashAlg` is not recognized, Chilkat falls back to `SHA1`. Applications should therefore pass a known algorithm name explicitly. Compare the returned fingerprint with a value obtained from a trusted source before sending credentials.

Returns `null` on failure

### Ssh.GetLastJsonData

`Chilkat 11.7.0 · js · Ssh · GetLastJsonData · method · since 9.5.0.79`

```javascript
GetLastJsonData(json);
```

· return: `undefined`  
· json: `CkJsonObject`

Copies structured diagnostic information from the most recently called method into the `JsonObject` in `json`. Many methods do not produce additional JSON details; in those cases the object may contain little or no information.

Authentication passwords and private-key passphrases are not included in this diagnostic JSON.

### Ssh.GetReceivedBd

`Chilkat 11.7.0 · js · Ssh · GetReceivedBd · method · since 11.4.0`

```javascript
var success = GetReceivedBd(channelNum, bd);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· bd: `CkBinData`

Appends all bytes currently accumulated in the normal receive buffer for `channelNum` to `bd`, then clears the channel receive buffer.

Existing bytes in `bd` are preserved and the received bytes are appended. If the method fails, such as for an invalid channel, `bd` is left unchanged.

Returns true for success, false for failure.

### Ssh.GetReceivedNumBytes

`Chilkat 11.7.0 · js · Ssh · GetReceivedNumBytes · method`

```javascript
var intVal = GetReceivedNumBytes(channelNum);
```

· return: `int`  
· channelNum: `int`

Returns the number of bytes currently available in the normal receive buffer for `channelNum`. It does not include bytes in the separate stderr buffer when `StderrToStdout` is `false`.

Returns `-1` when the channel number is invalid or its retained resources have been released. After a normal `Disconnect` or abrupt transport loss, bytes received earlier can remain available and this method can still return their count even though the channel is no longer active or enumerable. A subsequent `Connect` clears retained data from the previous session.

Buffered bytes can also remain after a timeout or cancellation. After normal channel completion, a later unrelated SSH operation can finalize and discard the completed channel record. Query and drain the buffer promptly.

Retrieve normal bytes with `GetReceivedData`, `GetReceivedDataN`, `GetReceivedBd`, or a text getter. Retrieve separate stderr with `GetReceivedStderr` or `GetReceivedStderrText`.

### Ssh.GetReceivedSb

`Chilkat 11.7.0 · js · Ssh · GetReceivedSb · method · since 11.6.0`

```javascript
var success = GetReceivedSb(channelNum, charset, sb);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· charset: `string`  
· sb: `CkStringBuilder`

Decodes and appends to `sb` all text currently accumulated in the normal receive buffer for `channelNum`, using `charset`. The receive buffer is cleared after the text is returned.

For a valid retained channel with no buffered data, an empty string is returned successfully. For an invalid or no-longer-retained channel, the string-returning API reports failure. After channel completion, retrieve text immediately before unrelated SSH operations can discard the completed channel record.

When `StripColorCodes` is `true`, ANSI SGR color/style sequences are removed from the returned normal text. Other terminal-control sequences can remain.

See [Supported Charsets](https://www.chilkatsoft.com/charsets_supported_by_chilkat.asp).

Returns true for success, false for failure.

### Ssh.GetReceivedStderrText

`Chilkat 11.7.0 · js · Ssh · GetReceivedStderrText · method`

```javascript
var strVal = GetReceivedStderrText(channelNum, charset);
```

· return: `string`  
· channelNum: `int`  
· charset: `string`

Decodes and returns all text currently accumulated in the separate stderr buffer for `channelNum`, using `charset`. The stderr buffer is cleared after the text is returned.

For a valid retained channel with no separate stderr, an empty string is returned successfully. For an invalid or no-longer-retained channel, the string-returning API reports failure. Retrieve stderr immediately after completion, before another SSH operation can discard the completed channel record.

`StripColorCodes` is not applied to stderr text. Text getters do not retain an incomplete multibyte sequence for a later call; use raw bytes and a stateful application decoder for streaming multibyte data.

See [Supported Charsets](https://www.chilkatsoft.com/charsets_supported_by_chilkat.asp).

Returns `null` on failure

### Ssh.GetReceivedText

`Chilkat 11.7.0 · js · Ssh · GetReceivedText · method`

```javascript
var strVal = GetReceivedText(channelNum, charset);
```

· return: `string`  
· channelNum: `int`  
· charset: `string`

Decodes and returns all text currently accumulated in the normal receive buffer for `channelNum`, using `charset`. The receive buffer is cleared after the text is returned.

For a valid retained channel with no buffered data, an empty string is returned successfully. For an invalid or no-longer-retained channel, the string-returning API reports failure. After channel completion, retrieve text immediately before unrelated SSH operations can discard the completed channel record.

When `StripColorCodes` is `true`, ANSI SGR color/style sequences are removed from the returned normal text. Other terminal-control sequences can remain.

See [Supported Charsets](https://www.chilkatsoft.com/charsets_supported_by_chilkat.asp).

Returns `null` on failure

### Ssh.GetReceivedTextS

`Chilkat 11.7.0 · js · Ssh · GetReceivedTextS · method`

```javascript
var strVal = GetReceivedTextS(channelNum, substr, charset);
```

· return: `string`  
· channelNum: `int`  
· substr: `string`  
· charset: `string`

Decodes text in the normal receive buffer for `channelNum` and performs a literal, case-sensitive search for `substr` using `charset`.

If found, the method returns and removes everything through and including the first occurrence. If not found, it returns an empty string successfully and leaves the buffer unchanged. An empty `substr` is invalid and causes failure without consuming the buffer.

When `StripColorCodes` is `true`, SGR sequences are removed for both the substring search and the returned value. The method consumes the corresponding original raw bytes, including the stripped escape sequences.

As with other destructive text getters, incomplete multibyte sequences are not retained as decoder state for a later call. Retrieve completed-channel text before unrelated SSH operations can remove the retained channel record.

Returns `null` on failure

### Ssh.OpenCustomChannel

`Chilkat 11.7.0 · js · Ssh · OpenCustomChannel · method`

```javascript
var intVal = OpenCustomChannel(channelType);
```

· return: `int`  
· channelType: `string`

Requests a custom SSH channel whose application-defined channel type is supplied in `channelType`. The SSH server must implement that channel type. On success, returns the channel number used by the normal channel send, receive, EOF, CLOSE, and release methods.

Returns `-1` if the server rejects the channel. In that case, `ChannelOpenFailCode` and `ChannelOpenFailReason` contain the server-provided failure information. The underlying SSH connection normally remains open, `CheckConnection` remains `true`, and other channels can be opened and used afterward.

A channel-open rejection does not set `DisconnectCode` or `DisconnectReason` unless the server also sends an SSH `DISCONNECT`. Object-level configuration settings are unchanged.

### Ssh.OpenDirectTcpIpChannel

`Chilkat 11.7.0 · js · Ssh · OpenDirectTcpIpChannel · method`

```javascript
var intVal = OpenDirectTcpIpChannel(targetHostname, targetPort);
```

· return: `int`  
· targetHostname: `string`  
· targetPort: `int`

Opens a `direct-tcpip` channel through the SSH server to `targetHostname` and `targetPort`. The target name is sent to and resolved by the SSH server, not by the client computer. It must therefore be resolvable and reachable from the server's network environment. A numeric IPv4 address may be supplied to avoid remote DNS-name resolution.

Each successful call creates one independent raw TCP byte stream. Multiple channels to the same target may be open concurrently. Bytes sent with `ChannelSend*` methods are forwarded to the target, and bytes returned by the target are read with `ChannelRead*` or `ChannelReceive*` methods. For example, when the target is an SSH server, its SSH identification line is received as ordinary channel data. The channel is enumerated with type `direct-tcpip`.

Returns the new channel number on success, or `-1` if the SSH server rejects or cannot establish the target connection. On server rejection, inspect `ChannelOpenFailCode` and `ChannelOpenFailReason`. Name-resolution and target-connection failures normally leave the underlying SSH connection open.

### Ssh.OpenSessionChannel

`Chilkat 11.7.0 · js · Ssh · OpenSessionChannel · method`

```javascript
var intVal = OpenSessionChannel();
```

· return: `int`

Opens a new SSH session channel. The SSH transport must already be connected and user authentication must have completed successfully. Calling this method before `Connect` or before authentication returns `-1`. A failure caused by missing authentication does not by itself close the SSH transport.

Opening a session channel does not start a shell, execute a command, or start a subsystem. After opening the channel, send the appropriate session request.

```
1. Connect
2. Authenticate
3. OpenSessionChannel
4. Optionally send preparatory requests such as SendReqPty or SendReqSetEnv
5. Send one primary request: SendReqExec, SendReqShell, or SendReqSubsystem
```

Returns an opaque channel number on success, or `-1` on failure. Do not assume channel numbers start at `0`, are sequential, or are reused in a predictable way.

### Ssh.PeekReceivedText

`Chilkat 11.7.0 · js · Ssh · PeekReceivedText · method`

```javascript
var strVal = PeekReceivedText(channelNum, charset);
```

· return: `string`  
· channelNum: `int`  
· charset: `string`

Returns the text currently buffered in the normal receive buffer for `channelNum`, decoded using `charset`, without removing any bytes.

For a valid empty buffer, it returns an empty string successfully. `StripColorCodes` is not applied; terminal escape sequences are returned as buffered. Because the operation is nondestructive, it is useful for checking whether a complete multibyte sequence or logical delimiter has arrived before calling a destructive text getter.

Returns `null` on failure

### Ssh.QuickCmdCheck

`Chilkat 11.7.0 · js · Ssh · QuickCmdCheck · method · since 9.5.0.65`

```javascript
var intVal = QuickCmdCheck(pollTimeoutMs);
```

· return: `int`  
· pollTimeoutMs: `int`

Waits up to `pollTimeoutMs` milliseconds for any command previously started by `QuickCmdSend` to complete. A value of `0` performs a nonblocking check. Manually opened exec channels are not returned by this method.

| Return value | Meaning |
| :--- | :--- |
| `>= 0` | The channel number of a completed quick command. Each completed channel is returned only once. |
| `-1` | Pending quick commands exist, but none completed before the timeout. |
| `-2` | No quick commands remain to be checked, or an error occurred such as loss of the SSH connection. Examine `LastErrorText` and the connection state when the distinction matters. |

After a channel number is returned, retrieve its stdout, stderr, and exit status with the normal channel methods. The channel is not returned again on the next check, even before `ChannelRelease` is called.

### Ssh.QuickCmdSend

`Chilkat 11.7.0 · js · Ssh · QuickCmdSend · method · since 9.5.0.65`

```javascript
var intVal = QuickCmdSend(command);
```

· return: `int`  
· command: `string`

Starts a remote command and immediately returns its channel number, allowing multiple commands to run concurrently on the same authenticated SSH connection. Internally, this method opens a session channel and sends an exec request.

`command` is encoded according to `ReqExecCharset`. The returned channel is visible through `NumOpenChannels`, `GetChannelNumber`, and `GetChannelType`, and remains owned by the application. Use `QuickCmdCheck` to detect completion, retrieve output and exit status with the normal channel methods, and then call `ChannelRelease`. Returns `-1` on failure.

### Ssh.QuickCommand

`Chilkat 11.7.0 · js · Ssh · QuickCommand · method · since 9.5.0.65`

```javascript
var strVal = QuickCommand(command, charset);
```

· return: `string`  
· command: `string`  
· charset: `string`

Executes one noninteractive remote command and returns the stdout collected as text. Internally, this method opens a session channel, sends an exec request, receives the command output through EOF, and decodes the stdout using `charset`. `ReqExecCharset` controls the encoding used to send `command`.

The final SSH channel `CLOSE` can still be pending when this method returns. The internal channel may therefore remain temporarily visible in `NumOpenChannels`, often with EOF already received but CLOSE not yet processed. Simply sleeping does not process pending SSH messages. A later SSH operation, such as `WaitForChannelMessage` or another `QuickCommand`, processes the final close and removes the previous channel.

**Remote exit status is not reflected in the return value:** A command that exits nonzero may still return its stdout normally. An empty string can mean a successful command produced no stdout, or that a failed command wrote only to stderr. When `StderrToStdout` is `false`, separately received stderr is not included in the returned text. Exit status may or may not have arrived at the instant this method returns.

Use `QuickCmdSend`/`QuickCmdCheck` or the explicit channel workflow when the application must reliably inspect stderr, provide stdin, or obtain the remote exit status. Do not depend on the temporary internal channel created by this convenience method.

Returns `null` on failure

### Ssh.QuickShell

`Chilkat 11.7.0 · js · Ssh · QuickShell · method · since 9.5.0.65`

```javascript
var intVal = QuickShell();
```

· return: `int`

Starts a remote shell using the simplified sequence `OpenSessionChannel` → `SendReqPty` → `SendReqShell`. The default PTY size is 80 columns by 24 rows. Returns the open shell channel number on success, or `-1` on failure.

The method returns after the shell request is accepted; it does not wait for or consume the initial login text or shell prompt. Use the returned channel with the normal send and receive methods, then allow the shell to close and call `ChannelRelease` after retrieving the required output and exit information.

### Ssh.ReKey

`Chilkat 11.7.0 · js · Ssh · ReKey · method`

```javascript
var success = ReKey();
```

· return: `boolean`; `true` for success, `false` for failure

Initiates SSH key re-exchange and waits for it to complete. Either client or server may initiate rekeying at any time.

RFC 4253 recommends changing keys after approximately one gigabyte of transferred data or one hour of connection time, whichever occurs first. In normal use, servers initiate rekeying as needed and Chilkat handles it transparently.

Returns true for success, false for failure.

### Ssh.SendIgnore

`Chilkat 11.7.0 · js · Ssh · SendIgnore · method`

```javascript
var success = SendIgnore();
```

· return: `boolean`; `true` for success, `false` for failure

Sends an SSH `IGNORE` message. The server does not reply, but a successful send helps verify that the connection is still writable. No channel is required.

Returns true for success, false for failure.

### Ssh.SendReqExec

`Chilkat 11.7.0 · js · Ssh · SendReqExec · method`

```javascript
var success = SendReqExec(channelNum, commandLine);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· commandLine: `string`

Requests execution of `commandLine` on the session channel identified by `channelNum`. The command text is sent using `ReqExecCharset`.

**Request acceptance is not command success:** A `true` return means the SSH server accepted the `exec` request. The remote command can still fail, be missing, or exit with a nonzero status. Receive the channel to completion, then use `ChannelReceivedExitStatus` and `GetChannelExitStatus` to determine the remote process result.

An exec channel is used for one command. Open a new session channel for each independent command. A second exec request on the same channel is normally rejected, while the first command continues running.

After the request is accepted, data sent with `ChannelSendData` or `ChannelSendString` becomes the command’s standard input. Call `ChannelSendEof` when no more input will be sent; stdout and stderr may still be received afterward.

Returns true for success, false for failure.

See also:

- [Note about sending commands that produce no output.](http://www.cknotes.com/?p=322)
- [Note about sending interactive commands such as "more"](http://www.cknotes.com/?p=323)

### Ssh.SendReqPty

`Chilkat 11.7.0 · js · Ssh · SendReqPty · method`

```javascript
var success = SendReqPty(channelNum, termType, widthInChars, heightInChars, widthInPixels, heightInPixels);
```

**Full documentation for this method (same in every language):** [Requesting a PTY in the SSH Protocol](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/ssh_request_pty.md) · [SSH server will not include the command prompt if no PTY is requested](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/ssh_no_command_prompt_if_no_pty.md)

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· termType: `string`  
· widthInChars: `int`  
· heightInChars: `int`  
· widthInPixels: `int`  
· heightInPixels: `int`

**Recommendation for automation:** Do not request a pseudo-terminal unless the remote command or application specifically requires terminal behavior. Most automated SSH applications should operate without a PTY so that stdout and stderr remain clean, predictable, and easier to parse.

Requests a pseudo-terminal for session channel `channelNum`. The request must be sent before the primary `SendReqExec` or `SendReqShell` request.

The `termType` argument identifies the terminal type and normally becomes the remote session's `TERM` environment variable. The server and remote applications use this value to look up terminal capabilities in their `terminfo` or `termcap` database. The character and pixel dimensions describe the terminal window. Terminal modes previously added with `SetTtyMode` are included in the request.

When no PTY is requested, the remote shell or command normally sees standard input and output as pipes rather than a terminal. Shells and programs commonly detect this using a check such as `isatty()` and operate in non-interactive mode. In that mode, the server normally does not send a shell prompt, does not echo submitted commands, and avoids terminal-oriented output such as ANSI color and cursor-control sequences. Shell startup behavior can vary according to the remote shell and its configuration.

| Request type without a PTY | Typical behavior |
| :--- | :--- |
| `exec` | The server runs the requested command, returns its stdout and stderr, supplies EOF/CLOSE and usually an exit status, and then ends the channel. No command prompt is included. |
| `shell` | The application may stream multiple newline-terminated commands through the channel as through a raw pipe. The server normally returns only command output, without prompts or echoed input. |

Without a prompt, an application must not wait for text such as `user@host:~$` to determine when a command is finished. For an `exec` request, use the SSH protocol state: receive through channel EOF/CLOSE and inspect the exit status with `ChannelReceivedExitStatus` and `GetChannelExitStatus`. For a long-lived shell channel, append a unique sentinel to each submitted command and receive until that sentinel is found.

**If a PTY is required for automation:** Prefer `dumb` for `termType` unless the remote program genuinely needs a more capable terminal. A `dumb` terminal advertises little more than sequential text input and output, so well-behaved programs generally avoid color, cursor movement, screen clearing, and other terminal-control sequences. This is often the best choice for commands such as `sudo` prompts or network-device CLIs that require a PTY but whose output still needs to be parsed.

| Terminal type | When to use it |
| :--- | :--- |
| `dumb` | Recommended when a PTY is mandatory but plain, sequential text is preferred. Full-screen programs such as `vim`, `top`, or `htop` may refuse to run or work poorly because cursor addressing is unavailable. |
| `xterm` or `xterm-256color` | Use only when the client is prepared to handle a capable terminal stream containing cursor movement, screen-control sequences, text attributes, and possibly color. Chilkat does not emulate an xterm terminal. |
| `vt100` or `vt220` | Useful for compatibility with older terminal-oriented systems or devices. These still support cursor movement and control sequences. |
| `linux` or `console` | Describe operating-system console terminals and should be used only when the application behaves like that console. |
| `screen` or `tmux` | Describe terminal-multiplexer environments and are appropriate only when their capabilities are actually expected. |

The terminal type is a declaration of capabilities, not a filter applied by Chilkat. A remote application can ignore `TERM`, force color, or emit escape sequences regardless of the selected type. If needed, also try sending environment requests such as `NO_COLOR=1` with `SendReqSetEnv`. Servers commonly restrict client-supplied environment variables, so setting `termType` to `dumb` in the PTY request is generally more reliable than attempting to set `TERM` separately.

A PTY changes remote-process behavior. Programs may display prompts, echo input, enable line buffering, execute interactive startup logic, emit terminal-control sequences, or alter formatting. Chilkat does not perform terminal emulation. A PTY also normally combines the remote process's stdout and stderr into one terminal stream, so `StderrToStdout` cannot preserve separate stderr on such a channel.

**Only one PTY request per channel:** Do not call this method a second time for the same channel. Some SSH servers treat a duplicate PTY request as a protocol error and disconnect the entire SSH session.

```
Recommended automation workflow:
1. OpenSessionChannel
2. Do not call SendReqPty unless terminal behavior is required
3. If a PTY is required but plain text is preferred, use termType = "dumb"
4. SendReqExec, or SendReqShell when multiple commands are required
5. Receive output and use SSH channel state, exit status, or a unique sentinel to detect completion
```

Returns true for success, false for failure.

### Ssh.SendReqSetEnv

`Chilkat 11.7.0 · js · Ssh · SendReqSetEnv · method`

```javascript
var success = SendReqSetEnv(channelNum, name, value);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· name: `string`  
· value: `string`

Requests that the server set environment variable `name` to `value` for the session channel identified by `channelNum`. Send environment requests before the primary `exec`, `shell`, or `subsystem` request.

Multiple variables may be requested. If the server accepts repeated requests for the same name, the later value is used. An empty value is allowed. The server controls which names are accepted; for example, an OpenSSH configuration can accept selected locale variables while rejecting arbitrary names.

A `true` return means the server accepted this environment request. A rejected request returns `false` but normally leaves the channel and SSH connection usable, so the application can continue with the primary request. A request sent after the primary request has started is normally rejected.

Returns true for success, false for failure.

### Ssh.SendReqShell

`Chilkat 11.7.0 · js · Ssh · SendReqShell · method`

```javascript
var success = SendReqShell(channelNum);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`

Starts a remote shell on the open session channel identified by `channelNum`. A shell can be requested without a PTY when the server permits it. For an interactive terminal session, call `SendReqPty` first.

A `true` return means the server accepted the shell request. This method does not wait for, detect, or remove a shell prompt. Login messages, prompts, command echo, and command output all arrive as ordinary channel data.

**Command boundaries are application-defined:** SSH does not identify when an individual shell command finishes. Use a prompt pattern only when it is reliably known, or append a unique sentinel to each command and receive until that sentinel is found.

Send commands with `ChannelSendString` using the line ending expected by the remote shell or device. Unix-like shells normally accept LF; other systems may require CRLF or another terminator. Multiple commands may be sent sequentially until the shell exits or the channel closes.

Returns true for success, false for failure.

### Ssh.SendReqSignal

`Chilkat 11.7.0 · js · Ssh · SendReqSignal · method`

```javascript
var success = SendReqSignal(channelNum, signalName);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· signalName: `string`

Requests delivery of `signalName` to the remote process running on `channelNum`. Send the request after the exec process, shell, or subsystem has started. Supported signal names are:

```
ABRT  ALRM  FPE  HUP  ILL  INT  KILL
PIPE  QUIT  SEGV TERM USR1 USR2
```

These are Unix-style signals and are effective only when supported by the SSH server, remote operating system, and target process. A `true` return indicates that the SSH request succeeded; the process may handle, ignore, or otherwise respond to the signal according to remote behavior.

Returns true for success, false for failure.

### Ssh.SendReqSubsystem

`Chilkat 11.7.0 · js · Ssh · SendReqSubsystem · method`

```javascript
var success = SendReqSubsystem(channelNum, subsystemName);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· subsystemName: `string`

Requests the predefined subsystem named by `subsystemName` on session channel `channelNum`. A `true` return means the server accepted the subsystem request; subsequent protocol data is exchanged with the normal channel send and receive methods.

If the server rejects the subsystem, this method returns `false` and the channel normally remains open and reusable for another primary request such as `SendReqExec`. Once a subsystem request is accepted, do not send an `exec`, `shell`, or second subsystem request on that channel.

For example, the SSH `sftp` subsystem can be started this way, but applications should normally use the `SFtp` class instead of implementing the SFTP protocol directly over an `Ssh` channel.

Returns true for success, false for failure.

### Ssh.SendReqWindowChange

`Chilkat 11.7.0 · js · Ssh · SendReqWindowChange · method`

```javascript
var success = SendReqWindowChange(channelNum, widthInChars, heightInRows, pixWidth, pixHeight);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· widthInChars: `int`  
· heightInRows: `int`  
· pixWidth: `int`  
· pixHeight: `int`

Notifies the server that the terminal dimensions changed for the PTY associated with `channelNum`. `widthInChars` and `heightInRows` specify the character dimensions; `pixWidth` and `pixHeight` specify the pixel dimensions.

This request may be sent after the PTY is allocated, either before or after starting the shell or exec process. The tested OpenSSH servers applied the new character dimensions to an active shell.

Returns true for success, false for failure.

### Ssh.SendReqX11Forwarding

`Chilkat 11.7.0 · js · Ssh · SendReqX11Forwarding · method`

```javascript
var success = SendReqX11Forwarding(channelNum, singleConnection, authProt, authCookie, screenNum);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· singleConnection: `boolean`  
· authProt: `string`  
· authCookie: `string`  
· screenNum: `int`

Sends an SSH X11-forwarding request on the session channel in `channelNum`. `singleConnection` controls whether forwarding is limited to a single connection; `authProt` through `screenNum` provide the X11 authentication protocol, cookie, and screen number.

This low-level method exposes the SSH connection-protocol request. The application is responsible for supplying appropriate X11 values and handling forwarded X11 channels.

Returns true for success, false for failure.

### Ssh.SendReqXonXoff

`Chilkat 11.7.0 · js · Ssh · SendReqXonXoff · method`

```javascript
var success = SendReqXonXoff(channelNum, clientCanDo);
```

· return: `boolean`; `true` for success, `false` for failure  
· channelNum: `int`  
· clientCanDo: `boolean`

Deprecated for practical use. This method should not be used.

Returns true for success, false for failure.

### Ssh.SetAllowedAlgorithms

`Chilkat 11.7.0 · js · Ssh · SetAllowedAlgorithms · method · since 9.5.0.99`

```javascript
var success = SetAllowedAlgorithms(json);
```

· return: `boolean`; `true` for success, `false` for failure  
· json: `CkJsonObject`

Applies an explicit allow-list of SSH negotiation algorithms supplied in `json`. Use this method before `Connect` when security policy or server compatibility requires precise control over accepted host-key, key-exchange, cipher, MAC, or compression algorithms.

Returns true for success, false for failure.

### Ssh.SetTtyMode

`Chilkat 11.7.0 · js · Ssh · SetTtyMode · method`

```javascript
var success = SetTtyMode(ttyName, ttyValue);
```

· return: `boolean`; `true` for success, `false` for failure  
· ttyName: `string`  
· ttyValue: `int`

Adds or updates one TTY mode to be included in a later `SendReqPty` request. `ttyName` is the mode name and `ttyValue` is its integer value. Call this method before `SendReqPty`, once for each mode to set. For example, `SetTtyMode("ECHO", 0)` requests that command input not be echoed by the allocated terminal.

Supported mode names include:

```
VINTR VQUIT VERASE VKILL VEOF VEOL VEOL2 VSTART VSTOP
VSUSP VDSUSP VREPRINT VWERASE VLNEXT VFLUSH VSWTCH VSTATUS
VDISCARD IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC
IXON IXANY IXOFF IMAXBEL ISIG ICANON XCASE ECHO ECHOE ECHOK
ECHONL NOFLSH TOSTOP IEXTEN ECHOCTL ECHOKE PENDIN OPOST OLCUC
ONLCR OCRNL ONOCR ONLRET CS7 CS8 PARENB PARODD
TTY_OP_ISPEED TTY_OP_OSPEED
```

Most applications do not need to set TTY modes explicitly. Use `ClearTtyModes` before a later PTY request when previously configured modes should no longer be included.

Returns true for success, false for failure.

### Ssh.StartKeyboardAuth

`Chilkat 11.7.0 · js · Ssh · StartKeyboardAuth · method · since 9.5.0.46`

```javascript
var strVal = StartKeyboardAuth(login);
```

· return: `string`  
· login: `string`

Begins keyboard-interactive authentication for the login in `login`. The returned XML describes the server’s prompts and whether each response should be echoed.

```
<infoRequest numPrompts="N">
  <name>name</name>
  <instruction>instructions</instruction>
  <prompt1 echo="1_or_0">prompt text</prompt1>
  ...
</infoRequest>
```

If authentication immediately succeeds or fails, the returned XML instead has one of these forms:

```
<success>success message</success>

<error>error message</error>
```

Submit responses with `ContinueKeyboardAuth`.

Returns `null` on failure

### Ssh.WaitForChannelMessage

`Chilkat 11.7.0 · js · Ssh · WaitForChannelMessage · method · since 9.5.0.48`

```javascript
var intVal = WaitForChannelMessage(pollTimeoutMs);
```

· return: `int`  
· pollTimeoutMs: `int`

Waits for the next SSH channel message on any channel. The `pollTimeoutMs` argument controls this method:

- `0`: nonblocking check.
- `> 0`: wait up to the specified number of milliseconds.
- `< 0`: wait without a method-level timeout.

The explicit argument governs the wait; shorter values of `ReadTimeoutMs` or `IdleTimeoutMs` do not shorten it.

| Return value | Meaning |
| :--- | :--- |
| `>= 0` | The channel number associated with the message that was processed. |
| `-1` | No channel message arrived before the timeout. |
| `-2` | Another error occurred, such as a lost connection. |

The method processes one pending channel message. Ordinary data is appended to the appropriate channel buffer, and control messages can update EOF, CLOSE, and exit-status state. It does not consume bytes already buffered for the application.

A channel is not returned again merely because unread bytes remain buffered, but it can be returned again for a later stderr, EOF, exit-status, or CLOSE message.

Drain available stdout and stderr promptly after a channel number is returned. A later wait or poll that processes final closure can remove the completed channel record and make its buffered data and status unavailable.

## Events and callbacks

This binding has no event callbacks.

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/BinData.md), [`JsonObject`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/JsonObject.md), [`SecureString`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/SecureString.md), [`SshKey`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/SshKey.md), [`StringArray`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/StringArray.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/js/classes/StringBuilder.md)

