Ssh C++ Reference Documentation

CkSsh

Current Version: 11.5.0

Chilkat.Ssh

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.

Object Creation

// Local variable on the stack
CkSsh obj;

// Dynamically allocate/delete
CkSsh *pObj = new CkSsh();
// ...
delete pObj;

Properties

AbortCurrent
bool get_AbortCurrent(void);
void put_AbortCurrent(bool newVal);
Introduced in version 9.5.0.58

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.

When the abort is observed, Chilkat resets the property to false. If no operation is running, it is reset when the next method begins. A synchronous call may be aborted by setting this property from another thread.

top
AuthFailReason
int get_AuthFailReason(void);
Introduced in version 9.5.0.52

Contains an authentication failure code after AuthenticatePw, AuthenticatePk, or AuthenticatePwPk fails.

ValueMeaning
1Transport failure. Communication with the server was lost, or a read/write operation failed or timed out.
2Invalid key for public-key authentication. The key is malformed, unsupported, not private, or otherwise unsuitable.
3No mutually supported authentication method was available.
4SSH authentication protocol error. An unexpected or invalid message was received.
5The password or private key was rejected.
6The SSH session is already authenticated.
7The server requires a password change. See PasswordChangeRequested.

top
CaretControl
bool get_CaretControl(void);
void put_CaretControl(bool newVal);
Introduced in version 9.5.0.49

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

When set to true, sequences such as ^C, ^M, and ^? are translated before the text is sent.
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

top
ChannelOpenFailCode
int get_ChannelOpenFailCode(void);

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

CodeSymbolic name
1SSH_OPEN_ADMINISTRATIVELY_PROHIBITED
2SSH_OPEN_CONNECT_FAILED
3SSH_OPEN_UNKNOWN_CHANNEL_TYPE
4SSH_OPEN_RESOURCE_SHORTAGE

top
ChannelOpenFailReason
void get_ChannelOpenFailReason(CkString &str);
const char *channelOpenFailReason(void);

Contains the descriptive text associated with ChannelOpenFailCode after a channel-open request fails.

top
ClientIdentifier
void get_ClientIdentifier(CkString &str);
const char *clientIdentifier(void);
void put_ClientIdentifier(const char *newVal);

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.

top
ClientIpAddress
void get_ClientIpAddress(CkString &str);
const char *clientIpAddress(void);
void put_ClientIpAddress(const char *newVal);

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.

top
ClientPort
int get_ClientPort(void);
void put_ClientPort(int newVal);
Introduced in version 9.5.0.75

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.

top
ConnectTimeoutMs
int get_ConnectTimeoutMs(void);
void put_ConnectTimeoutMs(int newVal);

Specifies the maximum number of milliseconds to wait for the remote endpoint to accept the TCP connection.

When a proxy is used, this timeout applies to establishing the TCP connection to the proxy. It does not include the HTTP CONNECT exchange, proxy authentication, or SSH protocol negotiation.

top
DebugLogFilePath
void get_DebugLogFilePath(CkString &str);
const char *debugLogFilePath(void);
void put_DebugLogFilePath(const char *newVal);

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
DisconnectCode
int get_DisconnectCode(void);

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

When connection establishment fails, this property is cleared and does not retain a code from an earlier connection.

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

top
DisconnectReason
void get_DisconnectReason(CkString &str);
const char *disconnectReason(void);

Contains the descriptive text sent with the server’s SSH DISCONNECT message. See DisconnectCode for the corresponding RFC 4253 reason code.

When connection establishment fails, this property is cleared and does not retain text from an earlier connection.

top
EnableCompression
bool get_EnableCompression(void);
void put_EnableCompression(bool newVal);
Introduced in version 9.5.0.56

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.

top
EnableSecrets
bool get_EnableSecrets(void);
void put_EnableSecrets(bool newVal);
Introduced in version 11.5.0

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.

More Information and Examples
top
ForceCipher
void get_ForceCipher(CkString &str);
const char *forceCipher(void);
void put_ForceCipher(const char *newVal);

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.

top
HeartbeatMs
int get_HeartbeatMs(void);
void put_HeartbeatMs(int newVal);

Specifies the interval, in milliseconds, between AbortCheck event callbacks during operations that support progress events. The callback gives the application an opportunity to abort an operation before it completes.

The default is 0, which disables periodic AbortCheck callbacks.

More Information and Examples
top
HostKeyAlg
void get_HostKeyAlg(CkString &str);
const char *hostKeyAlg(void);
void put_HostKeyAlg(const char *newVal);

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.

top
HostKeyFingerprint
void get_HostKeyFingerprint(CkString &str);
const char *hostKeyFingerprint(void);

Contains the server host-key fingerprint after a successful connection. A typical value is:

ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5

This property is nonempty only while a valid SSH connection exists. It is empty when no valid connection exists, including after a failed connection attempt.

Use GetHostKeyFP when a specific hash algorithm or output format is required.

More Information and Examples
top
HttpProxyAuthMethod
void get_HttpProxyAuthMethod(CkString &str);
const char *httpProxyAuthMethod(void);
void put_HttpProxyAuthMethod(const char *newVal);

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

ValueBehavior
emptyAutomatically negotiate a supported authentication method with the proxy.
BasicUse HTTP Basic authentication.
NTLMUse 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.

top
HttpProxyDomain
void get_HttpProxyDomain(CkString &str);
const char *httpProxyDomain(void);
void put_HttpProxyDomain(const char *newVal);

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.

top
HttpProxyHostname
void get_HttpProxyHostname(CkString &str);
const char *httpProxyHostname(void);
void put_HttpProxyHostname(const char *newVal);

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.

More Information and Examples
top
HttpProxyPassword
void get_HttpProxyPassword(CkString &str);
const char *httpProxyPassword(void);
void put_HttpProxyPassword(const char *newVal);

Specifies the password used to authenticate with an HTTP proxy.

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

top
HttpProxyPort
int get_HttpProxyPort(void);
void put_HttpProxyPort(int newVal);

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.

top
HttpProxyUsername
void get_HttpProxyUsername(CkString &str);
const char *httpProxyUsername(void);
void put_HttpProxyUsername(const char *newVal);

Specifies the username used to authenticate with an HTTP proxy.

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

More Information and Examples
top
IdleTimeoutMs
int get_IdleTimeoutMs(void);
void put_IdleTimeoutMs(int newVal);

Specifies the maximum time, in milliseconds, that an SSH operation may remain without send or receive progress. The operation fails when no progress occurs for longer than this interval.

The default is 0, which allows an indefinite wait.

top
IsConnected
bool get_IsConnected(void);

Indicates Chilkat’s last known connection state. It becomes true after Connect successfully establishes the secure SSH transport. A failed Connect always leaves this property equal to false. It also becomes false after Disconnect or when another method detects that the connection has been lost.

Important: This property does not actively test the socket. A server may have closed an idle connection while this property still reports true. To verify the connection, first check this property and then call SendIgnore.

More Information and Examples
top
KeepSessionLog
bool get_KeepSessionLog(void);
void put_KeepSessionLog(bool newVal);

Controls whether SSH protocol traffic is accumulated in SessionLog. The default is false.

Session logging is intended for diagnostics. When enabled, the log continues to grow as the session proceeds, so disable it when it is no longer needed.

top
LastErrorHtml
void get_LastErrorHtml(CkString &str);
const char *lastErrorHtml(void);

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
void get_LastErrorText(CkString &str);
const char *lastErrorText(void);

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
void get_LastErrorXml(CkString &str);
const char *lastErrorXml(void);

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
bool get_LastMethodSuccess(void);
void put_LastMethodSuccess(bool newVal);

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
MaxPacketSize
int get_MaxPacketSize(void);
void put_MaxPacketSize(int newVal);

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.

top
NumOpenChannels
int get_NumOpenChannels(void);

Returns the number of channels currently open in this SSH session.

top
PasswordChangeRequested
bool get_PasswordChangeRequested(void);

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|

top
PreferIpv6
bool get_PreferIpv6(void);
void put_PreferIpv6(bool newVal);

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.

top
ReadTimeoutMs
int get_ReadTimeoutMs(void);
void put_ReadTimeoutMs(int newVal);

Specifies the maximum total time, in milliseconds, allowed for a read operation, even while data continues to arrive. The default is 0, meaning no total read-time limit.

IdleTimeoutMs limits how long a read may make no progress. ReadTimeoutMs limits the overall duration of the read.

top
ReqExecCharset
void get_ReqExecCharset(CkString &str);
const char *reqExecCharset(void);
void put_ReqExecCharset(const char *newVal);
Introduced in version 9.5.0.47

Specifies the character encoding used for command text sent by SendReqExec, QuickCommand, and QuickCmdSend. The default is ANSI; utf-8 is a common alternative.

top
ServerIdentifier
void get_ServerIdentifier(CkString &str);
const char *serverIdentifier(void);
Introduced in version 9.5.0.71

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

SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2

If connection establishment fails, this property is cleared, even if the server identifier was received earlier during the failed attempt. It does not retain a value from a previous connection.

top
SessionLog
void get_SessionLog(CkString &str);
const char *sessionLog(void);

Contains the in-memory SSH session log. Enable logging by setting KeepSessionLog to true.

This property contains log text; it is not a file path.

top
SocksHostname
void get_SocksHostname(CkString &str);
const char *socksHostname(void);
void put_SocksHostname(const char *newVal);

Specifies the SOCKS proxy hostname or IPv4 address. This property is used only when SocksVersion is 4 or 5.

top
SocksPassword
void get_SocksPassword(CkString &str);
const char *socksPassword(void);
void put_SocksPassword(const char *newVal);

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

top
SocksPort
int get_SocksPort(void);
void put_SocksPort(int newVal);

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

top
SocksUsername
void get_SocksUsername(CkString &str);
const char *socksUsername(void);
void put_SocksUsername(const char *newVal);

Specifies the SOCKS proxy username. This property is used only when SocksVersion is 4 or 5.

top
SocksVersion
int get_SocksVersion(void);
void put_SocksVersion(int newVal);

Selects whether and how a SOCKS proxy is used.

ValueBehavior
0Do not use a SOCKS proxy. This is the default. Chilkat may still use an HTTP proxy if both HttpProxyHostname and HttpProxyPort are set.
4Connect through a SOCKS4 proxy.
5Connect 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.

These proxy settings apply to both Connect and ConnectThroughSsh.

top
SoRcvBuf
int get_SoRcvBuf(void);
void put_SoRcvBuf(int newVal);

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.

top
SoSndBuf
int get_SoSndBuf(void);
void put_SoSndBuf(int newVal);

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.

top
StderrToStdout
bool get_StderrToStdout(void);
void put_StderrToStdout(bool newVal);

Controls whether 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 stderr separately with GetReceivedStderr or GetReceivedStderrText.

Many SSH servers send both streams as ordinary CHANNEL_DATA rather than using CHANNEL_EXTENDED_DATA for stderr. In that case, stdout and stderr cannot be separated regardless of this setting. Check SessionLog to see which packet types the server sent.

top
StripColorCodes
bool get_StripColorCodes(void);
void put_StripColorCodes(bool newVal);
Introduced in version 9.5.0.67

Controls whether terminal color escape sequences are removed from received text. The default is true. Set to false when the application needs the original terminal formatting codes.

top
TcpNoDelay
bool get_TcpNoDelay(void);
void put_TcpNoDelay(bool newVal);

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.

top
UncommonOptions
void get_UncommonOptions(CkString &str);
const char *uncommonOptions(void);
void put_UncommonOptions(const char *newVal);
Introduced in version 9.5.0.73

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

KeywordEffect
ForceUserAuthRsaSha1Forces 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-algsRemoves hmac-sha1-96, hmac-sha1, hmac-md5, and hmac-ripemd160 from the offered MAC algorithms.
ProtectFromVpnOn Android, bypasses an installed or active VPN.
+ssh-hmac-etmRe-enables Encrypt-then-MAC algorithms that are disabled by default as a Terrapin mitigation.
+chacha20-poly1305@openssh.comRe-enables chacha20-poly1305@openssh.com, which is disabled by default as a Terrapin mitigation.
Set connection-negotiation options before calling Connect.

top
UserAuthBanner
void get_UserAuthBanner(CkString &str);
const char *userAuthBanner(void);
void put_UserAuthBanner(const char *newVal);
Introduced in version 9.5.0.46

Contains a user-authentication banner received from the server during keyboard-interactive authentication. Check this property after calling StartKeyboardAuth and display it to the user when appropriate.

top
Utf8
bool get_Utf8(void);
void put_Utf8(bool newVal);

When set to true, all const char * arguments and return values are interpreted as UTF-8 strings. When set to false, they are interpreted as ANSI strings.

In Chilkat v11.0.0 and later, the default value is true. Before v11.0.0, it was false.

top
VerboseLogging
bool get_VerboseLogging(void);
void put_VerboseLogging(bool newVal);

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
void get_Version(CkString &str);
const char *version(void);

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

AuthenticatePk
bool AuthenticatePk(const char *username, CkSshKey &privateKey);

Authenticates the connected SSH session using public-key authentication. username identifies the server account, and privateKey supplies the matching private key. The corresponding public key must already be authorized for username on the server.

Call Connect first. After a failure, inspect AuthFailReason and LastErrorText.

Returns true for success, false for failure.

top
AuthenticatePkAsync (1)
CkTask *AuthenticatePkAsync(const char *username, CkSshKey &privateKey);

Creates an asynchronous task to call the AuthenticatePk method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
AuthenticatePw
bool AuthenticatePw(const char *login, const char *password);

Authenticates the connected SSH session using the login in login and the password in password.

A typical sequence is Connect followed by one authentication method. If the server requests a password change, see PasswordChangeRequested.

After a failure, inspect AuthFailReason and LastErrorText.

Returns true for success, false for failure.

top
AuthenticatePwAsync (1)
CkTask *AuthenticatePwAsync(const char *login, const char *password);

Creates an asynchronous task to call the AuthenticatePw method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
AuthenticatePwPk
bool AuthenticatePwPk(const char *username, const char *password, CkSshKey &privateKey);

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.

More Information and Examples
top
AuthenticatePwPkAsync (1)
CkTask *AuthenticatePwPkAsync(const char *username, const char *password, CkSshKey &privateKey);

Creates an asynchronous task to call the AuthenticatePwPk method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
AuthenticateSecPw
bool AuthenticateSecPw(CkSecureString &login, CkSecureString &password);
Introduced in version 9.5.0.71

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

Returns true for success, false for failure.

More Information and Examples
top
AuthenticateSecPwAsync (1)
CkTask *AuthenticateSecPwAsync(CkSecureString &login, CkSecureString &password);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPw method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
AuthenticateSecPwPk
bool AuthenticateSecPwPk(CkSecureString &username, CkSecureString &password, CkSshKey &privateKey);
Introduced in version 9.5.0.71

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.

top
AuthenticateSecPwPkAsync (1)
CkTask *AuthenticateSecPwPkAsync(CkSecureString &username, CkSecureString &password, CkSshKey &privateKey);
Introduced in version 9.5.0.71

Creates an asynchronous task to call the AuthenticateSecPwPk method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelIsOpen
bool ChannelIsOpen(int channelNum);

Returns true when the channel identified by channelNum is currently open; otherwise returns false.

top
ChannelPoll
int ChannelPoll(int channelNum, int pollTimeoutMs);

Polls the open channel in channelNum for incoming data, waiting at most pollTimeoutMs milliseconds. Data received by this method is placed in the channel’s internal receive buffer.

Return valueMeaning
-1An error occurred. Inspect LastErrorText, IsConnected, and ChannelIsOpen.
-2No additional data arrived before the applicable timeout.
0The channel has received EOF or is already closed.
> 0The number of bytes now available in the channel receive buffer. Retrieve them with a GetReceived* method.
top
ChannelPollAsync (1)
CkTask *ChannelPollAsync(int channelNum, int pollTimeoutMs);

Creates an asynchronous task to call the ChannelPoll method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelRead
int ChannelRead(int channelNum);

Reads incoming data from the open channel in channelNum. The first wait is limited by IdleTimeoutMs. Received bytes are accumulated in the channel’s internal receive buffer.

Return valueMeaning
-1An error occurred. Inspect LastErrorText, IsConnected, and ChannelIsOpen.
-2No additional data arrived before the applicable timeout.
0The channel has received EOF or is already closed.
> 0The number of bytes now available in the channel receive buffer. Retrieve them with a GetReceived* method.
top
ChannelReadAsync (1)
CkTask *ChannelReadAsync(int channelNum);

Creates an asynchronous task to call the ChannelRead method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelReadAndPoll
int ChannelReadAndPoll(int channelNum, int pollTimeoutMs);

Reads the channel in channelNum and continues reading until no additional data arrives for pollTimeoutMs milliseconds. The first wait uses IdleTimeoutMs; after data begins arriving, each subsequent wait uses pollTimeoutMs.

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 valueMeaning
-1An error occurred. Inspect LastErrorText, IsConnected, and ChannelIsOpen.
-2No additional data arrived before the applicable timeout.
0The channel has received EOF or is already closed.
> 0The number of bytes now available in the channel receive buffer. Retrieve them with a GetReceived* method.
top
ChannelReadAndPollAsync (1)
CkTask *ChannelReadAndPollAsync(int channelNum, int pollTimeoutMs);

Creates an asynchronous task to call the ChannelReadAndPoll method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelReadAndPoll2
int ChannelReadAndPoll2(int channelNum, int pollTimeoutMs, int maxNumBytes);

Works like ChannelReadAndPoll, but also returns as soon as the total available received data exceeds maxNumBytes bytes.

top
ChannelReadAndPoll2Async (1)
CkTask *ChannelReadAndPoll2Async(int channelNum, int pollTimeoutMs, int maxNumBytes);

Creates an asynchronous task to call the ChannelReadAndPoll2 method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelReceivedClose
bool ChannelReceivedClose(int channelNum);

Returns true if an SSH CLOSE message has been received for the channel in channelNum. After CLOSE, the channel is closed in both directions and no more data should be sent.

top
ChannelReceivedEof
bool ChannelReceivedEof(int channelNum);

Returns true if an SSH EOF message has been received for the channel in channelNum. EOF means the server will send no more data, but the client may still send data until the channel is closed.

top
ChannelReceivedExitStatus
bool ChannelReceivedExitStatus(int channelNum);

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

top
ChannelReceiveToClose
bool ChannelReceiveToClose(int channelNum);

Receives data on the channel in channelNum until the server closes the channel. On success, use GetReceivedNumBytes to inspect the buffered byte count and a GetReceived* method to retrieve the data.

Returns true for success, false for failure.

top
ChannelReceiveToCloseAsync (1)
CkTask *ChannelReceiveToCloseAsync(int channelNum);

Creates an asynchronous task to call the ChannelReceiveToClose method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelReceiveUntilMatch
bool ChannelReceiveUntilMatch(int channelNum, const char *matchPattern, const char *charset, bool caseSensitive);

Receives text on the channel in channelNum until the accumulated text matches the wildcard pattern in matchPattern. For example, *Hello World* waits until that text appears. charset specifies the character encoding, and caseSensitive controls case sensitivity.

The method may read beyond the matched text. Use GetReceivedTextS with the matching substring to remove and return only the text through the match.

Usage notes:
  • Set ReadTimeoutMs to a nonzero value to prevent an indefinite wait.
  • For shell automation, a dumb PTY minimizes terminal escape sequences that may interfere with matching.
  • Consider StderrToStdout; merged stderr can also affect pattern matching.

Returns true for success, false for failure.

top
ChannelReceiveUntilMatchAsync (1)
CkTask *ChannelReceiveUntilMatchAsync(int channelNum, const char *matchPattern, const char *charset, bool caseSensitive);

Creates an asynchronous task to call the ChannelReceiveUntilMatch method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelReceiveUntilMatchN
bool ChannelReceiveUntilMatchN(int channelNum, CkStringArray &matchPatterns, const char *charset, bool caseSensitive);

Works like ChannelReceiveUntilMatch, but returns when any pattern contained in the StringArray passed in matchPatterns is matched. charset specifies the character encoding, and caseSensitive controls case sensitivity.

Set ReadTimeoutMs to a nonzero value to prevent an indefinite wait when none of the patterns arrives.

Returns true for success, false for failure.

More Information and Examples
top
ChannelReceiveUntilMatchNAsync (1)
CkTask *ChannelReceiveUntilMatchNAsync(int channelNum, CkStringArray &matchPatterns, const char *charset, bool caseSensitive);

Creates an asynchronous task to call the ChannelReceiveUntilMatchN method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelRelease
void ChannelRelease(int channelNum);
Introduced in version 9.5.0.44

Releases Chilkat’s internal resources for the channel in channelNum after it has been closed. Channels are released automatically when the Ssh object is disposed, so this method is normally needed only by long-running applications that open and close very large numbers of channels.

top
ChannelSendClose
bool ChannelSendClose(int channelNum);

Sends an SSH CLOSE message for the channel in channelNum, closing the channel in both directions.

Returns true for success, false for failure.

top
ChannelSendCloseAsync (1)
CkTask *ChannelSendCloseAsync(int channelNum);

Creates an asynchronous task to call the ChannelSendClose method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelSendEof
bool ChannelSendEof(int channelNum);

Sends an SSH EOF message on the channel in channelNum. After EOF is sent, no additional data may be sent on that channel, although data may still be received until the channel closes.

Returns true for success, false for failure.

top
ChannelSendEofAsync (1)
CkTask *ChannelSendEofAsync(int channelNum);

Creates an asynchronous task to call the ChannelSendEof method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ChannelSendString
bool ChannelSendString(int channelNum, const char *textData, const char *charset);

Encodes the text in textData using the character set named by charset, then sends the resulting bytes on the channel in channelNum.

See Supported Charsets. When CaretControl is true, caret sequences are translated to control characters before sending.

Returns true for success, false for failure.

top
ChannelSendStringAsync (1)
CkTask *ChannelSendStringAsync(int channelNum, const char *textData, const char *charset);

Creates an asynchronous task to call the ChannelSendString method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
CheckConnection
bool CheckConnection(void);
Introduced in version 9.5.0.46

Actively checks whether the underlying TCP socket is still connected to the SSH server. Unlike IsConnected, this method performs a connection check rather than returning only the last known state.

top
ClearTtyModes
void ClearTtyModes(void);

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

top
Connect
bool Connect(const char *domainName, int port);

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.

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 its channels are replaced.

The same Ssh object may be reused after Disconnect or after a failed connection attempt. A failed call always leaves IsConnected equal to false. Connection-related property settings remain in effect across disconnects and subsequent connection attempts.

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

Supported negotiation algorithms include:

CategoryAlgorithms
Host keyssh-ed25519, rsa-sha2-256, rsa-sha2-512, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-rsa, ssh-dss
Key exchangecurve25519-sha256, curve25519-sha256@libssh.org, NIST ECDH, DH group 1/14/16/18, and group-exchange SHA-1/SHA-256
CiphersAES CTR/CBC/GCM, Twofish CBC, Blowfish CBC, and optionally chacha20-poly1305@openssh.com
MACSHA-2, SHA-1, RIPEMD-160, MD5, and optionally OpenSSH Encrypt-then-MAC variants
Compressionnone, 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.

top
ConnectAsync (1)
CkTask *ConnectAsync(const char *domainName, int port);

Creates an asynchronous task to call the Connect method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ConnectThroughSsh
bool ConnectThroughSsh(CkSsh &ssh, const char *hostname, int port);
Introduced in version 9.5.0.55

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 on this object also apply to this connection. SOCKS takes precedence over HTTP proxy settings, using the same selection rules as Connect.

Returns true for success, false for failure.

More Information and Examples
top
ConnectThroughSshAsync (1)
CkTask *ConnectThroughSshAsync(CkSsh &ssh, const char *hostname, int port);
Introduced in version 9.5.0.55

Creates an asynchronous task to call the ConnectThroughSsh method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ContinueKeyboardAuth
bool ContinueKeyboardAuth(const char *response, CkString &outStr);
const char *continueKeyboardAuth(const char *response);
Introduced in version 9.5.0.46

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 true for success, false for failure.

More Information and Examples
top
ContinueKeyboardAuthAsync (1)
CkTask *ContinueKeyboardAuthAsync(const char *response);
Introduced in version 9.5.0.46

Creates an asynchronous task to call the ContinueKeyboardAuth method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
Disconnect
void Disconnect(void);

Closes the current SSH connection and releases all open channels associated with the session.

The Ssh object remains reusable. Connection-related property settings are not reset and remain in effect for subsequent calls to Connect. Every newly established connection begins unauthenticated, even if the object authenticated a previous session.

top
GetAuthMethods
bool GetAuthMethods(CkString &outStr);
const char *getAuthMethods(void);
Introduced in version 9.5.0.78

Queries the connected server for its supported user-authentication methods and returns a comma-separated string such as publickey,password,keyboard-interactive.

Call this method after Connect and before authenticating. The method intentionally disconnects after obtaining the list, so reconnect before attempting authentication.

Returns true for success, false for failure.

More Information and Examples
top
GetAuthMethodsAsync (1)
CkTask *GetAuthMethodsAsync(void);
Introduced in version 9.5.0.78

Creates an asynchronous task to call the GetAuthMethods method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
GetChannelExitStatus
int GetChannelExitStatus(int channelNum);

Returns the exit-status value received for the channel in channelNum. Call this method only after ChannelReceivedExitStatus returns true.

top
GetChannelNumber
int GetChannelNumber(int index);

Returns the channel number for the open channel at zero-based index index. Use NumOpenChannels to determine the valid index range. Returns -1 when index is out of range.

top
GetChannelType
bool GetChannelType(int index, CkString &outStr);
const char *getChannelType(int index);

Returns the type of the open channel at zero-based index index. Possible values include session, x11, forwarded-tcpip, and direct-tcpip.

Returns true for success, false for failure.

top
GetHostKeyFP
bool GetHostKeyFP(const char *hashAlg, bool includeKeyType, bool includeHashName, CkString &outStr);
const char *getHostKeyFP(const char *hashAlg, bool includeKeyType, bool includeHashName);
Introduced in version 9.5.0.92

Returns the connected server’s host-key fingerprint. hashAlg specifies the hash algorithm, such as SHA256, SHA384, SHA512, SHA1, MD5, or a SHA-3 variant. includeKeyType controls whether the host-key type is included; includeHashName controls whether the hash name is included.

includeKeyTypeincludeHashNameExample format
truetruessh-rsa SHA256:L7sQgnpnoBwRoyIYXAFB...
truefalsessh-rsa L7sQgnpnoBwRoyIYXAFB...
falsetrueSHA256:L7sQgnpnoBwRoyIYXAFB...
falsefalseL7sQgnpnoBwRoyIYXAFB...

Possible host-key types include ssh-rsa, ECDSA types such as ecdsa-sha2-nistp256, ssh-ed25519, and ssh-dss.

Returns true for success, false for failure.

More Information and Examples
top
GetLastJsonData
void GetLastJsonData(CkJsonObject &json);
Introduced in version 9.5.0.79

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.

top
GetReceivedNumBytes
int GetReceivedNumBytes(int channelNum);

Returns the number of bytes currently available in the receive buffer for the channel in channelNum. Retrieve the bytes with GetReceivedData, GetReceivedDataN, or a text-retrieval method.

top
GetReceivedStderrText
bool GetReceivedStderrText(int channelNum, const char *charset, CkString &outStr);
const char *getReceivedStderrText(int channelNum, const char *charset);

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

See Supported Charsets.

Returns true for success, false for failure.

top
GetReceivedText
bool GetReceivedText(int channelNum, const char *charset, CkString &outStr);
const char *getReceivedText(int channelNum, const char *charset);

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

See Supported Charsets.

Returns true for success, false for failure.

top
GetReceivedTextS
bool GetReceivedTextS(int channelNum, const char *substr, const char *charset, CkString &outStr);
const char *getReceivedTextS(int channelNum, const char *substr, const char *charset);

Decodes text in the channel receive buffer and returns only the portion through the first occurrence of substr, inclusive. charset specifies the character set.

The returned portion is removed from the buffer. If substr is not found, an empty string is returned and the buffer is left unchanged.

Returns true for success, false for failure.

top
LoadTaskCaller
bool LoadTaskCaller(CkTask &task);
Introduced in version 9.5.0.80

Loads into this object the caller state associated with the asynchronous method represented by task. This is used by generated asynchronous wrappers to recover the object that initiated the task.

Returns true for success, false for failure.

top
OpenCustomChannel
int OpenCustomChannel(const char *channelType);

Requests a custom SSH channel whose application-defined channel type is supplied in channelType. On success, returns the channel number used by subsequent channel methods; returns -1 on failure.

top
OpenCustomChannelAsync (1)
CkTask *OpenCustomChannelAsync(const char *channelType);

Creates an asynchronous task to call the OpenCustomChannel method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
OpenDirectTcpIpChannel
int OpenDirectTcpIpChannel(const char *targetHostname, int targetPort);

Opens a direct-tcpip channel through the SSH server to the target host in targetHostname and port in targetPort. Bytes sent with ChannelSend* methods are forwarded to the target; data received from the target is read with ChannelRead* or ChannelReceive* methods.

Returns the new channel number on success, or -1 on failure.

top
OpenDirectTcpIpChannelAsync (1)
CkTask *OpenDirectTcpIpChannelAsync(const char *targetHostname, int targetPort);

Creates an asynchronous task to call the OpenDirectTcpIpChannel method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
OpenSessionChannel
int OpenSessionChannel(void);

Opens a new SSH session channel. Session channels are used for command execution, shells, PTY requests, environment variables, and related SSH connection-protocol requests.

1. Connect
2. Authenticate
3. OpenSessionChannel
4. SendReqExec or SendReqShell

Returns the new channel number on success, or -1 on failure.

top
OpenSessionChannelAsync (1)
CkTask *OpenSessionChannelAsync(void);

Creates an asynchronous task to call the OpenSessionChannel method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
PeekReceivedText
bool PeekReceivedText(int channelNum, const char *charset, CkString &outStr);
const char *peekReceivedText(int channelNum, const char *charset);

Returns the text currently buffered for the channel in channelNum, decoded using charset, without removing it from the receive buffer.

Returns true for success, false for failure.

top
QuickCmdCheck
int QuickCmdCheck(int pollTimeoutMs);
Introduced in version 9.5.0.65

Waits up to pollTimeoutMs milliseconds for any command previously started by QuickCmdSend to complete.

Return valueMeaning
>= 0The channel number of a completed command.
-1No command completed before the timeout.
-2An error occurred, such as loss of the SSH connection.
top
QuickCmdCheckAsync (1)
CkTask *QuickCmdCheckAsync(int pollTimeoutMs);
Introduced in version 9.5.0.65

Creates an asynchronous task to call the QuickCmdCheck method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
QuickCmdSend
int QuickCmdSend(const char *command);
Introduced in version 9.5.0.65

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

command is the command. ReqExecCharset controls its encoding. Returns -1 on failure.

top
QuickCmdSendAsync (1)
CkTask *QuickCmdSendAsync(const char *command);
Introduced in version 9.5.0.65

Creates an asynchronous task to call the QuickCmdSend method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
QuickCommand
bool QuickCommand(const char *command, const char *charset, CkString &outStr);
const char *quickCommand(const char *command, const char *charset);
Introduced in version 9.5.0.65

Executes one remote command and returns its complete output as text. Internally, this method opens a session channel, sends an exec request, receives until the channel closes, and decodes the buffered output.

command is the command. charset specifies the output character set, such as utf-8 or ansi. ReqExecCharset controls the encoding used to send the command.

Returns true for success, false for failure.

More Information and Examples
top
QuickCommandAsync (1)
CkTask *QuickCommandAsync(const char *command, const char *charset);
Introduced in version 9.5.0.65

Creates an asynchronous task to call the QuickCommand method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
QuickShell
int QuickShell(void);
Introduced in version 9.5.0.65

Starts a remote shell using the simplified sequence OpenSessionChannelSendReqPtySendReqShell. Returns the shell channel number on success, or -1 on failure.

top
QuickShellAsync (1)
CkTask *QuickShellAsync(void);
Introduced in version 9.5.0.65

Creates an asynchronous task to call the QuickShell method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
ReKey
bool ReKey(void);

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.

top
ReKeyAsync (1)
CkTask *ReKeyAsync(void);

Creates an asynchronous task to call the ReKey method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendIgnore
bool SendIgnore(void);

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.

More Information and Examples
top
SendIgnoreAsync (1)
CkTask *SendIgnoreAsync(void);

Creates an asynchronous task to call the SendIgnore method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqExec
bool SendReqExec(int channelNum, const char *commandLine);

Requests execution of the command line in commandLine on the session channel in channelNum. commandLine should contain the complete command and its arguments.

One exec request per channel: An exec channel is used for a single command. The server normally closes it when the command finishes. Open a new session channel before sending another exec request.

This starts a noninteractive command, not a persistent shell. ReqExecCharset controls the encoding of the command text.

Returns true for success, false for failure.

top
SendReqExecAsync (1)
CkTask *SendReqExecAsync(int channelNum, const char *commandLine);

Creates an asynchronous task to call the SendReqExec method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqPty
bool SendReqPty(int channelNum, const char *termType, int widthInChars, int heightInChars, int widthInPixels, int heightInPixels);

Requests a pseudo-terminal for the session channel in channelNum. termType specifies the terminal type. For character-oriented terminals such as vt100, set widthInChars and heightInChars to the character dimensions and typically set widthInPixels and heightInPixels to 0. For pixel-oriented terminals such as xterm, provide pixel dimensions in widthInPixels and heightInPixels.

For automation that does not need terminal emulation, dumb is often preferable because it minimizes escape sequences in command output.
1. Connect
2. Authenticate
3. OpenSessionChannel
4. SendReqPty, if required
5. SendReqShell

Returns true for success, false for failure.

More Information and Examples
top
SendReqPtyAsync (1)
CkTask *SendReqPtyAsync(int channelNum, const char *termType, int widthInChars, int heightInChars, int widthInPixels, int heightInPixels);

Creates an asynchronous task to call the SendReqPty method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqSetEnv
bool SendReqSetEnv(int channelNum, const char *name, const char *value);

Requests that the server set the environment variable named by name to the value in value for the session channel in channelNum. The server may accept or reject environment-variable requests according to its configuration.

Returns true for success, false for failure.

top
SendReqSetEnvAsync (1)
CkTask *SendReqSetEnvAsync(int channelNum, const char *name, const char *value);

Creates an asynchronous task to call the SendReqSetEnv method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqShell
bool SendReqShell(int channelNum);

Starts an interactive shell on the open session channel in channelNum. Some servers require a PTY request first; in that case call SendReqPty before this method.

After the shell starts, send commands with ChannelSendString. Include the line ending expected by the remote shell, commonly CRLF.

Returns true for success, false for failure.

More Information and Examples
top
SendReqShellAsync (1)
CkTask *SendReqShellAsync(int channelNum);

Creates an asynchronous task to call the SendReqShell method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqSignal
bool SendReqSignal(int channelNum, const char *signalName);

Requests delivery of the signal named by signalName to the remote process running on the channel in channelNum. Supported signal names are:

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

These are Unix-style signals and are relevant when the SSH server and remote process support them.

Returns true for success, false for failure.

top
SendReqSignalAsync (1)
CkTask *SendReqSignalAsync(int channelNum, const char *signalName);

Creates an asynchronous task to call the SendReqSignal method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqSubsystem
bool SendReqSubsystem(int channelNum, const char *subsystemName);

Requests the predefined subsystem named by subsystemName on the session channel in channelNum. For example, SFTP clients start the sftp subsystem.

Returns true for success, false for failure.

top
SendReqSubsystemAsync (1)
CkTask *SendReqSubsystemAsync(int channelNum, const char *subsystemName);

Creates an asynchronous task to call the SendReqSubsystem method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqWindowChange
bool SendReqWindowChange(int channelNum, int widthInChars, int heightInRows, int pixWidth, int pixHeight);

Notifies the server that the client-side terminal size changed for the channel in channelNum. widthInChars and heightInRows specify the character dimensions; pixWidth and pixHeight specify the pixel dimensions.

top
SendReqWindowChangeAsync (1)
CkTask *SendReqWindowChangeAsync(int channelNum, int widthInChars, int heightInRows, int pixWidth, int pixHeight);

Creates an asynchronous task to call the SendReqWindowChange method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqX11Forwarding
bool SendReqX11Forwarding(int channelNum, bool singleConnection, const char *authProt, const char *authCookie, int screenNum);

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.
top
SendReqX11ForwardingAsync (1)
CkTask *SendReqX11ForwardingAsync(int channelNum, bool singleConnection, const char *authProt, const char *authCookie, int screenNum);

Creates an asynchronous task to call the SendReqX11Forwarding method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SendReqXonXoff
bool SendReqXonXoff(int channelNum, bool clientCanDo);

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

top
SendReqXonXoffAsync (1)
CkTask *SendReqXonXoffAsync(int channelNum, bool clientCanDo);

Creates an asynchronous task to call the SendReqXonXoff method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
SetAllowedAlgorithms
bool SetAllowedAlgorithms(CkJsonObject &json);
Introduced in version 9.5.0.99

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.

More Information and Examples
top
SetTtyMode
bool SetTtyMode(const char *ttyName, int ttyValue);

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, commonly 0 or 1. Call this method once for each mode to set.

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 to remove all previously configured modes.
top
StartKeyboardAuth
bool StartKeyboardAuth(const char *login, CkString &outStr);
const char *startKeyboardAuth(const char *login);
Introduced in version 9.5.0.46

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 true for success, false for failure.

More Information and Examples
top
StartKeyboardAuthAsync (1)
CkTask *StartKeyboardAuthAsync(const char *login);
Introduced in version 9.5.0.46

Creates an asynchronous task to call the StartKeyboardAuth method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
WaitForChannelMessage
int WaitForChannelMessage(int pollTimeoutMs);
Introduced in version 9.5.0.48

Waits up to pollTimeoutMs milliseconds for an incoming SSH message on any channel. Pass 0 to poll without waiting.

Return valueMeaning
>= 0The channel number on which a message arrived.
-1The wait timed out.
-2Another error occurred, such as a lost connection.
A returned channel number identifies where a message is pending; it does not consume the message. Call an appropriate ChannelRead* or ChannelReceive* method, then retrieve buffered data with a GetReceived* method.
top
WaitForChannelMessageAsync (1)
CkTask *WaitForChannelMessageAsync(int pollTimeoutMs);
Introduced in version 9.5.0.48

Creates an asynchronous task to call the WaitForChannelMessage method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top

Events

To implement an event callback, your application would define and implement a class that inherits from CkBaseProgress. Your application can implement methods to override some or all of the default/empty method implementations of the CkBaseProgress base class.

For example:

  CkSsh ssh;

  MySshProgress callbackObj;

  ssh.put_EventCallbackObject(&callbackObj);

MySshProgress example:

#include "CkBaseProgress.h"

class MySshProgress : public CkBaseProgress {

  public:
    MySshProgress();
    virtual ~MySshProgress();

    void AbortCheck(bool  *abort);

    void PercentDone(int pctDone, bool  *abort);

    void ProgressInfo(const char *name, const char *value);

    void TaskCompleted(CkTask &task);

};
AbortCheck
void AbortCheck(bool *abort);

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

More Information and Examples
top
PercentDone
void PercentDone(int pctDone, bool *abort);

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to true. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples
top
ProgressInfo
void ProgressInfo(const char *name, const char *value);

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

Note: Some Chilkat methods don't fire any ProgressInfo events.

More Information and Examples
top
TaskCompleted
void TaskCompleted(CkTask &task);

Called from the background thread when an asynchronous task completes.

top

Deprecated

ChannelSendData Deprecated
bool ChannelSendData(int channelNum, CkByteData &byteData);

Sends the bytes in byteData on the channel identified by channelNum.

Returns true for success, false for failure.

top
ChannelSendDataAsync Deprecated (1)
CkTask *ChannelSendDataAsync(int channelNum, CkByteData &byteData);

Creates an asynchronous task to call the ChannelSendData method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top
GetReceivedBd Deprecated
bool GetReceivedBd(int channelNum, CkBinData &bd);
Introduced in version 11.4.0

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

Returns true for success, false for failure.

top
GetReceivedData Deprecated
bool GetReceivedData(int channelNum, CkByteData &outBytes);

Returns all bytes currently accumulated in the receive buffer for the channel in channelNum, then clears that buffer.

Returns true for success, false for failure.

top
GetReceivedDataN Deprecated
bool GetReceivedDataN(int channelNum, int maxNumBytes, CkByteData &outBytes);

Returns and removes at most maxNumBytes bytes from the receive buffer for the channel in channelNum. Any remaining bytes stay buffered for a later call.

Returns true for success, false for failure.

top
GetReceivedStderr Deprecated
bool GetReceivedStderr(int channelNum, CkByteData &outBytes);
Introduced in version 9.5.0.48

Returns all bytes currently accumulated in the stderr buffer for the channel in channelNum, then clears that stderr buffer.

When StderrToStdout is true—the default—stderr is merged into the normal receive buffer instead.

Returns true for success, false for failure.

top
LastJsonData
CkJsonObject *LastJsonData(void);
Introduced in version 9.5.0.79
This method is deprecated.

Deprecated. Use GetLastJsonData instead.

For methods that provide structured diagnostic details, returns a JsonObject describing what occurred during the most recent operation. Many methods do not produce additional JSON data.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

top