Ssh C Library Reference

Ssh

A client-side SSH2 implementation for executing commands and shell sessions on Unix/Windows SSH servers.

Create/Dispose

HCkSsh CkSsh_Create(void);

Creates an instance of the CkSsh object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkSsh_Dispose(HCkSsh handle);

Objects created by calling CkSsh_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

C "Properties"

int CkSsh_getChannelOpenFailCode(HCkSsh cHandle);

If a request to open a channel fails, this property contains a code that identifies the reason for failure. The reason codes are defined in RFC 4254 and are reproduced here:

             Symbolic name                           reason code
             -------------                           -----------
            SSH_OPEN_ADMINISTRATIVELY_PROHIBITED          1
            SSH_OPEN_CONNECT_FAILED                       2
            SSH_OPEN_UNKNOWN_CHANNEL_TYPE                 3
            SSH_OPEN_RESOURCE_SHORTAGE                    4

void CkSsh_getChannelOpenFailReason(HCkSsh cHandle, HCkString retval);

The descriptive text corresponding to the ChannelOpenFailCode property.

void CkSsh_getClientIdentifier(HCkSsh cHandle, HCkString retval);
void CkSsh_putClientIdentifier(HCkSsh cHandle, const char *newVal);

The client-identifier string to be used when connecting to an SSH/SFTP server. Defaults to "SSH-2.0-PuTTY_Local:_Jun_27_2008_16:28:58". (This string is used to mimic PuTTY because some servers are known to disconnect from clients with unknown client identifiers.)

int CkSsh_getConnectTimeoutMs(HCkSsh cHandle);
void CkSsh_putConnectTimeoutMs(HCkSsh cHandle, int newVal);

Maximum number of milliseconds to wait when connecting to an SSH server.

int CkSsh_getDisconnectCode(HCkSsh cHandle);

If the SSH server sent a DISCONNECT message when closing the connection, this property contains the "reason code" as specified in RFC 4253:

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

void CkSsh_getDisconnectReason(HCkSsh cHandle, HCkString retval);

If the SSH/ server sent a DISCONNECT message when closing the connection, this property contains a descriptive string for the "reason code" as specified in RFC 4253.

int CkSsh_getHeartbeatMs(HCkSsh cHandle);
void CkSsh_putHeartbeatMs(HCkSsh cHandle, int newVal);

This is the number of milliseconds between each AbortCheck event callback. The AbortCheck callback allows an application to abort any SSH operation prior to completion. If HeartbeatMs is 0 (the default), no AbortCheck event callbacks will fire.

void CkSsh_getHostKeyFingerprint(HCkSsh cHandle, HCkString retval);

Set after connecting to an SSH server. The format of the fingerprint looks like this: "ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5"

void CkSsh_getHttpProxyAuthMethod(HCkSsh cHandle, HCkString retval);
void CkSsh_putHttpProxyAuthMethod(HCkSsh cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

void CkSsh_getHttpProxyHostname(HCkSsh cHandle, HCkString retval);
void CkSsh_putHttpProxyHostname(HCkSsh cHandle, const char *newVal);

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

void CkSsh_getHttpProxyPassword(HCkSsh cHandle, HCkString retval);
void CkSsh_putHttpProxyPassword(HCkSsh cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

int CkSsh_getHttpProxyPort(HCkSsh cHandle);
void CkSsh_putHttpProxyPort(HCkSsh cHandle, int newVal);

If an HTTP proxy is to be used, set this property to the HTTP proxy port number. (Two commonly used HTTP proxy ports are 8080 and 3128.)

void CkSsh_getHttpProxyUsername(HCkSsh cHandle, HCkString retval);
void CkSsh_putHttpProxyUsername(HCkSsh cHandle, const char *newVal);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

int CkSsh_getIdleTimeoutMs(HCkSsh cHandle);
void CkSsh_putIdleTimeoutMs(HCkSsh cHandle, int newVal);

Causes SSH operations to fail when progress for sending or receiving data halts for more than this number of milliseconds. Setting IdleTimeoutMs = 0 (the default) allows the application to wait indefinitely.

BOOL CkSsh_getIsConnected(HCkSsh cHandle);

Returns true if the component is connected to an SSH server.

Note: The IsConnected property is set to true after successfully completing the Connect method call. The IsConnected property will only be set to false by calling Disconnect, or by the failure of another method call such that the disconnection is detected.

BOOL CkSsh_getKeepSessionLog(HCkSsh cHandle);
void CkSsh_putKeepSessionLog(HCkSsh cHandle, BOOL newVal);

Controls whether communications to/from the SSH server are saved to the SessionLog property. The default value is false. If this property is set to true, the contents of the SessionLog property will continuously grow as SSH activity transpires. The purpose of the KeepSessionLog / SessionLog properties is to help in debugging any future problems that may arise.

void CkSsh_getLastErrorHtml(HCkSsh cHandle, HCkString retval);

Error information in HTML format for the last method called.

void CkSsh_getLastErrorText(HCkSsh cHandle, HCkString retval);

Error information in plain-text format for the last method called.

void CkSsh_getLastErrorXml(HCkSsh cHandle, HCkString retval);

Error information in XML format for the last method called.

int CkSsh_getMaxPacketSize(HCkSsh cHandle);
void CkSsh_putMaxPacketSize(HCkSsh cHandle, int newVal);

The maximum packet length to be used in the SSH transport protocol. The default value is 8192. (This should generally be left unchanged.)

int CkSsh_getNumOpenChannels(HCkSsh cHandle);

The number of currently open channels.

int CkSsh_getReadTimeoutMs(HCkSsh cHandle);
void CkSsh_putReadTimeoutMs(HCkSsh cHandle, int newVal);

The maximum amount of time to allow for reading messages/data from the SSH server. This is different from the IdleTimeoutMs property. The IdleTimeoutMs is the maximum amount of time to wait while no incoming data is arriving. The ReadTimeoutMs is the maximum amount of time to allow for reading data even if data is continuing to arrive. The default value of 0 indicates an infinite timeout value.

void CkSsh_getSessionLog(HCkSsh cHandle, HCkString retval);

Contains a log of the messages sent to/from the SSH server. To enable session logging, set the KeepSessionLog property = true. Note: This property is not a filename -- it is a string property that contains the session log data.

void CkSsh_getSocksHostname(HCkSsh cHandle, HCkString retval);
void CkSsh_putSocksHostname(HCkSsh cHandle, const char *newVal);

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

void CkSsh_getSocksPassword(HCkSsh cHandle, HCkString retval);
void CkSsh_putSocksPassword(HCkSsh cHandle, const char *newVal);

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

int CkSsh_getSocksPort(HCkSsh cHandle);
void CkSsh_putSocksPort(HCkSsh cHandle, int newVal);

The SOCKS4/SOCKS5 proxy port. The default value is 1080. This property only applies if a SOCKS proxy is used (if the SocksVersion property is set to 4 or 5).

void CkSsh_getSocksUsername(HCkSsh cHandle, HCkString retval);
void CkSsh_putSocksUsername(HCkSsh cHandle, const char *newVal);

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

int CkSsh_getSocksVersion(HCkSsh cHandle);
void CkSsh_putSocksVersion(HCkSsh cHandle, int newVal);

SocksVersion May be set to one of the following integer values:

0 - No SOCKS proxy is used. This is the default.
4 - Connect via a SOCKS4 proxy.
5 - Connect via a SOCKS5 proxy.

BOOL CkSsh_getTcpNoDelay(HCkSsh cHandle);
void CkSsh_putTcpNoDelay(HCkSsh cHandle, BOOL newVal);

Controls whether the TCP_NODELAY socket option is used for the underlying TCP/IP socket. The default value is true. This disables the Nagle algorithm and allows for better performance when small amounts of data are sent to/from the SSH server.

BOOL CkSsh_getUtf8(HCkSsh cHandle);
void CkSsh_putUtf8(HCkSsh cHandle, BOOL newVal);

To be documented soon...

BOOL CkSsh_getVerboseLogging(HCkSsh cHandle);
void CkSsh_putVerboseLogging(HCkSsh cHandle, BOOL newVal);

To be documented soon...

void CkSsh_getVersion(HCkSsh cHandle, HCkString retval);

A version string such as "2.1.0". This indicates the version of the Chilkat component.

C "Methods"

BOOL CkSsh_AuthenticatePk(HCkSsh cHandle, const char *username, HCkSshKey privateKey);

Authenticates with the SSH server using public-key authentication. The corresponding public key must have been installed on the SSH server for the username. Authentication will succeed if the matching privateKey is provided.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_AuthenticatePw(HCkSsh cHandle, const char *login, const char *password);

Authenticates with the SSH server using a login and password.

An SSH session always begins by first calling Connect to connect to the SSH server, and then calling either AuthenticatePw or AuthenticatePk to login.

Important: When reporting problems, please send the full contents of the LastErrorText property to support@chilkatsoft.com.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelIsOpen(HCkSsh cHandle, int channelNum);

Returns true if the channel indicated by channelNum is open. Otherwise returns false.

int CkSsh_ChannelPoll(HCkSsh cHandle, int channelNum, int pollTimeoutMs);

Polls for incoming data on an open channel. This method will read a channel, waiting at most pollTimeoutMs milliseconds for data to arrive. Return values are as follows:

-1 -- Error. Check the IsConnected property to see if the connection to the SSH server is still valid. Also, call ChannelIsOpen to see if the channel remains open. The LastErrorText property will contain more detailed information regarding the error.

-2 -- No additional data was received prior to the poll timeout.

>0 -- Additional data was received and the return value indicates how many bytes are available to be "picked up". Methods that read data on a channel do not return the received data directly. Instead, they return an integer to indicate how many bytes are available to be "picked up". An application picks up the available data by calling GetReceivedData or GetReceivedText.

int CkSsh_ChannelRead(HCkSsh cHandle, int channelNum);

Reads incoming data on an open channel. This method will read a channel, waiting at most IdleTimeoutMs milliseconds for data to arrive. Return values are as follows:

-1 -- Error. Check the IsConnected property to see if the connection to the SSH server is still valid. Also, call ChannelIsOpen to see if the channel remains open. The LastErrorText property will contain more detailed information regarding the error.

-2 -- No additional data was received prior to the IdleTimeoutMs timeout.

>0 -- Additional data was received and the return value indicates how many bytes are available to be "picked up". Methods that read data on a channel do not return the received data directly. Instead, they return an integer to indicate how many bytes are available to be "picked up". An application picks up the available data by calling GetReceivedData or GetReceivedText.

int CkSsh_ChannelReadAndPoll(HCkSsh cHandle, int channelNum, int pollTimeoutMs);

Reads incoming data on an open channel and continues reading until no data arrives for pollTimeoutMs milliseconds. The first read will wait a max of IdleTimeoutMs milliseconds before timing out. Subsequent reads wait a max of pollTimeoutMs milliseconds before timing out.

The idea behind ChannelReadAndPoll is to capture the output of a shell command. One might imagine the typical sequence of events when executing a shell command to be like this: (1) client sends command to server, (2) server executes the command (i.e. it's computing...), potentially taking some amount of time, (3) output is streamed back to the client. It makes sense for the client to wait a longer period of time for the first data to arrive, but once it begins arriving, the timeout can be shortened. This is exactly what ChannelReadAndPoll does -- the first timeout is controlled by the IdleTimeoutMs property, while the subsequent reads (once output starts flowing) is controlled by pollTimeoutMs.

Return values are as follows:
-1 -- Error. Check the IsConnected property to see if the connection to the SSH server is still valid. Also, call ChannelIsOpen to see if the channel remains open. The LastErrorText property will contain more detailed information regarding the error.

-2 -- No additional data was received prior to the IdleTimeoutMs timeout.

>0 -- Additional data was received and the return value indicates how many bytes are available to be "picked up". Methods that read data on a channel do not return the received data directly. Instead, they return an integer to indicate how many bytes are available to be "picked up". An application picks up the available data by calling GetReceivedData or GetReceivedText.

int CkSsh_ChannelReadAndPoll2(HCkSsh cHandle, int channelNum, int pollTimeoutMs, int maxNumBytes);

The same as ChannelReadAndPoll, except this method will return as soon as maxNumBytes is exceeded, which may be as large as the MaxPacketSize property setting.

BOOL CkSsh_ChannelReceiveToClose(HCkSsh cHandle, int channelNum);

Reads incoming data on an open channel until the channel is closed by the server. If successful, the number of bytes available to be "picked up" can be determined by calling GetReceivedNumBytes. The received data may be retrieved by calling GetReceivedData or GetReceivedText.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelReceiveUntilMatch(HCkSsh cHandle, int channelNum, const char *matchPattern, const char *charset, BOOL caseSensitive);

Reads incoming text data on an open channel until the received data matches the matchPattern. For example, to receive data until the string "Hello World" arrives, set matchPattern equal to "*Hello World*". charset indicates the character encoding of the text being received ("iso-8859-1" for example). caseSensitive may be set to true for case sensitive matching, or false for case insensitive matching.

Returns true if text data matching matchPattern was received and is available to be picked up by calling GetReceivedText (or GetReceivedTextS). IMPORTANT: This method may read beyond the matching text. Call GetReceivedTextS to extract only the data up-to and including the matching text.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelReceiveUntilMatchN(HCkSsh cHandle, int channelNum, HCkStringArray matchPatterns, const char *charset, BOOL caseSensitive);

To be documented soon...

BOOL CkSsh_ChannelReceivedClose(HCkSsh cHandle, int channelNum);

true if a CLOSE message has been received on the channel indicated by channelNum. When a CLOSE is received, no subsequent data should be sent in either direction -- the channel is closed in both directions.

BOOL CkSsh_ChannelReceivedEof(HCkSsh cHandle, int channelNum);

true if an EOF message has been received on the channel indicated by channelNum. When an EOF is received, no more data will be forthcoming on the channel. However, data may still be sent in the opposite direction.

BOOL CkSsh_ChannelReceivedExitStatus(HCkSsh cHandle, int channelNum);

true if an exit status code was received on the channel. Otherwise false.

BOOL CkSsh_ChannelSendClose(HCkSsh cHandle, int channelNum);

Sends a CLOSE message to the server for the channel indicated by channelNum. This closes both directions of the bidirectional channel.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelSendData(HCkSsh cHandle, int channelNum, HCkByteData data);

Sends byte data on the channel indicated by channelNum.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelSendEof(HCkSsh cHandle, int channelNum);

Sends an EOF for the channel indicated by channelNum. Once an EOF is sent, no additional data may be sent on the channel. However, the channel remains open and additional data may still be received from the server.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_ChannelSendString(HCkSsh cHandle, int channelNum, const char *strData, const char *charset);

Sends character data on the channel indicated by channelNum. The text is converted to the charset indicated by charset prior to being sent. A list of supported charset values may be found on this page: Supported Charsets.

Returns TRUE for success, FALSE for failure.

void CkSsh_ClearTtyModes(HCkSsh cHandle);

To be documented soon.

BOOL CkSsh_Connect(HCkSsh cHandle, const char *hostname, int port);

Connects to the SSH server at hostname: port

Returns TRUE for success, FALSE for failure.

void CkSsh_Disconnect(HCkSsh cHandle);

Disconnects from the SSH server.

int CkSsh_GetChannelExitStatus(HCkSsh cHandle, int channelNum);

Returns the exit status code for a channel. This method should only be called if an exit status has been received. You may check to see if the exit status was received by calling ChannelReceivedExitStatus.

int CkSsh_GetChannelNumber(HCkSsh cHandle, int index);

Returns the channel number for the Nth open channel. Indexing begins at 0, and the number of currently open channels is indicated by the NumOpenChannels property. Returns -1 if the index is out of range.

BOOL CkSsh_GetChannelType(HCkSsh cHandle, int index, HCkString outStr);

Returns a string describing the channel type for the Nth open channel. Channel types are: "session", "x11", "forwarded-tcpip", and "direct-tcpip".

void CkSsh_GetReceivedData(HCkSsh cHandle, int channelNum, HCkByteData outBytes);

Returns the accumulated data received on the channel indicated by channelNum and clears the channel's internal receive buffer.

BOOL CkSsh_GetReceivedDataN(HCkSsh cHandle, int channelNum, int numBytes, HCkByteData outBytes);

Same as GetReceivedData, but a maximum of maxNumBytes bytes is returned.

int CkSsh_GetReceivedNumBytes(HCkSsh cHandle, int channelNum);

Returns the number of bytes available in the internal receive buffer for the specified channelNum. The received data may be retrieved by calling GetReceivedData or GetReceivedText.

void CkSsh_GetReceivedStderr(HCkSsh cHandle, int channelNum, HCkByteData outBytes);

To be documented soon.

BOOL CkSsh_GetReceivedText(HCkSsh cHandle, int channelNum, const char *charset, HCkString outStr);

Returns the accumulated text received on the channel indicated by channelNum and clears the channel's internal receive buffer. The charset indicates the charset of the character data in the internal receive buffer. A list of supported charset values may be found on this page: Supported Charsets.

BOOL CkSsh_GetReceivedTextS(HCkSsh cHandle, int channelNum, const char *substr, const char *charset, HCkString outStr);

The same as GetReceivedText, except only the text up to and including substr is returned. The text returned is removed from the internal receive buffer. If the substr was not found in the internal receive buffer, an empty string is returned and the internal receive buffer is not modified.

int CkSsh_OpenCustomChannel(HCkSsh cHandle, const char *channelType);

Opens a custom channel with a custom server that uses the SSH protocol. The channelType is application-defined.

If successful, the channel number is returned. This is the number that should be passed to any method requiring a channel number. A -1 is returned upon failure.

int CkSsh_OpenDirectTcpIpChannel(HCkSsh cHandle, const char *hostname, int port);

Open a direct-tcpip channel for port forwarding. Data sent on the channel via ChannelSend* methods is sent to the SSH server and then forwarded to targetHostname: targetPort. The SSH server automatically forwards data received from targetHostname: targetPort to the SSH client. Therefore, calling ChannelRead* and ChannelReceive* methods is equivalent to reading directly from targetHostname: targetPort.

If successful, the channel number is returned. This is the number that should be passed to any method requiring a channel number. A -1 is returned upon failure.

int CkSsh_OpenSessionChannel(HCkSsh cHandle);

Opens a new session channel. Almost everything you will do with the Chilkat SSH component will involve opening a session channel. The normal sequence of operation is typically this: 1) Connect to the SSH server. 2) Authenticate. 3) Open a session channel. 4) do something on the channel such as opening a shell, execute a command, etc.

If successful, the channel number is returned. This is the number that should be passed to any method requiring a channel number. A -1 is returned upon failure.

BOOL CkSsh_PeekReceivedText(HCkSsh cHandle, int channelNum, const char *charset, HCkString outStr);

This is the same as GetReceivedText, except the internal receive buffer is not cleared.

BOOL CkSsh_ReKey(HCkSsh cHandle);

Initiates a re-key with the SSH server. The ReKey method does not return until the key re-exchange is complete.

RFC 4253 (the SSH Transport Layer Protocol) recommends that keys be changed after each gigabyte of transmitted data or after each hour of connection time, whichever comes sooner. Key re-exchange is a public-key operation and requires a fair amount of processing power and should not be performed too often. Either side (client or server) may initiate a key re-exchange at any time.

In most cases, a server will automatically initiate key re-exchange whenever it deems necessary, and the Chilkat SSH component handles these transparently. For example, if the Chilkat SSH component receives a re-key message from the server while in the process of receiving data on a channel, it will automatically handle the key re-exchange and the application will not even realize that an underlying key re-exchange occurred.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SaveLastError(HCkSsh cHandle, const char *filename);

Saves the last error information to an XML formatted file.

BOOL CkSsh_SendIgnore(HCkSsh cHandle);

Sends an IGNORE message to the SSH server. This is one way of verifying that the connection to the SSH server is open and valid. The SSH server does not response it an IGNORE message, it simply ignores it. IGNORE messages are not associated with a channel (in other words, you do not need to first open a channel prior to sending an IGNORE message).

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqExec(HCkSsh cHandle, int channelNum, const char *command);

Initiates execution of a command on the channel specified by channelNum. The commandLine contains the full command line including any command-line parameters (just as you would type the command at a shell prompt).

The user's default shell (typically defined in /etc/password in UNIX systems) is started on the SSH server to execute the command.

Important: A channel only exists for a single request. You may not call SendReqExec multiple times on the same open channel. The reason is that the SSH server automatically closes the channel at the end of the exec. The solution is to call OpenSessionChannel to get a new channel, and then call SendReqExec using the new channel. It is OK to have more than one channel open simultaneously.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqPty(HCkSsh cHandle, int channelNum, const char *xTermEnvVar, int widthInChars, int heightInRows, int pixWidth, int pixHeight);

Requests a pseudo-terminal for a session channel. If the termType is a character oriented terminal ("vt100" for example), then widthInChars and heightInChars would be set to non-zero values, while widthInPixels and heightInPixels may be set to 0. If termType is pixel-oriented, such as "xterm", the reverse is true (i.e. set widthInPixels and heightInPixels, but set widthInChars and heightInChars equal to 0).

In most cases, you probably don't even want terminal emulation. In that case, try setting termType = "dumb". Terminal emulation causes terminal escape sequences to be included with shell command output. A "dumb" terminal should have no escape sequences.

Some SSH servers allow a shell to be started (via the SendReqShell method) without the need to first request a pseudo-terminal. The normal sequence for starting a remote shell is as follows:

1) Connect
2) Authenticate
3) OpenSessionChannel
4) Request a PTY via this method if necessary.
5) Start a shell by calling SendReqShell

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqSetEnv(HCkSsh cHandle, int channelNum, const char *name, const char *value);

Sets an environment variable in the remote shell.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqShell(HCkSsh cHandle, int channelNum);

Starts a shell on an open session channel. Some SSH servers require that a PTY (pseudo-terminal) first be requested prior to starting a shell. In that case, call SendReqPty prior to calling this method. Once a shell is started, commands may be sent by calling ChannelSendString. (Don't forget to terminate commands with a CRLF).

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqSignal(HCkSsh cHandle, int channelNum, const char *signalName);

Delivers a signal to the remote process/service. signalName is one of the following: ABRT, ALRM, FPE, HUP, ILL, INT, KILL, PIPE, QUIT, SEGV, TERM, USR1, USR2. (Obviously, these are UNIX signals, so the remote SSH server would need to be a Unix/Linux system.)

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqSubsystem(HCkSsh cHandle, int channelNum, const char *subsystemName);

Executes a pre-defined subsystem. The SFTP protocol (Secure File Transfer Protocol) is started by the Chilkat SFTP component by starting the "sftp" subsystem.

Returns TRUE for success, FALSE for failure.

BOOL CkSsh_SendReqWindowChange(HCkSsh cHandle, int channelNum, int widthInChars, int heightInRows, int pixWidth, int pixHeight);

To be documented soon...

BOOL CkSsh_SendReqX11Forwarding(HCkSsh cHandle, int channelNum, BOOL singleConnection, const char *authProt, const char *authCookie, int screenNum);

To be documented soon...

BOOL CkSsh_SendReqXonXoff(HCkSsh cHandle, int channelNum, BOOL clientCanDo);

To be documented soon...

BOOL CkSsh_SetTtyMode(HCkSsh cHandle, const char *name, int value);

To be documented soon...

BOOL CkSsh_UnlockComponent(HCkSsh cHandle, const char *unlockCode);

Unlocks the component. This must be called once prior to calling any other method. A fully-functional 30-day trial is automatically started when an arbitrary string is passed to this method. For example, passing "Hello", or "abc123" will unlock the component for the 1st thirty days after the initial install.

Returns TRUE for success, FALSE for failure.

const char *CkSsh_channelOpenFailReason(HCkSsh cHandle);

The descriptive text corresponding to the ChannelOpenFailCode property.

const char *CkSsh_clientIdentifier(HCkSsh cHandle);

The client-identifier string to be used when connecting to an SSH/SFTP server. Defaults to "SSH-2.0-PuTTY_Local:_Jun_27_2008_16:28:58". (This string is used to mimic PuTTY because some servers are known to disconnect from clients with unknown client identifiers.)

const char *CkSsh_disconnectReason(HCkSsh cHandle);

If the SSH/ server sent a DISCONNECT message when closing the connection, this property contains a descriptive string for the "reason code" as specified in RFC 4253.

const char *CkSsh_getChannelType(HCkSsh cHandle, int index);

Returns a string describing the channel type for the Nth open channel. Channel types are: "session", "x11", "forwarded-tcpip", and "direct-tcpip".

const char *CkSsh_getReceivedText(HCkSsh cHandle, int channelNum, const char *charset);

Returns the accumulated text received on the channel indicated by channelNum and clears the channel's internal receive buffer. The charset indicates the charset of the character data in the internal receive buffer. A list of supported charset values may be found on this page: Supported Charsets.

const char *CkSsh_getReceivedTextS(HCkSsh cHandle, int channelNum, const char *substr, const char *charset);

The same as GetReceivedText, except only the text up to and including substr is returned. The text returned is removed from the internal receive buffer. If the substr was not found in the internal receive buffer, an empty string is returned and the internal receive buffer is not modified.

const char *CkSsh_hostKeyFingerprint(HCkSsh cHandle);

Set after connecting to an SSH server. The format of the fingerprint looks like this: "ssh-rsa 1024 68:ff:d1:4e:6c:ff:d7:b0:d6:58:73:85:07:bc:2e:d5"

const char *CkSsh_httpProxyAuthMethod(HCkSsh cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy authentication method name. Valid choices are "LOGIN" or "NTLM".

const char *CkSsh_httpProxyHostname(HCkSsh cHandle);

If an HTTP proxy is to be used, set this property to the HTTP proxy hostname or IPv4 address (in dotted decimal notation).

const char *CkSsh_httpProxyPassword(HCkSsh cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy password.

const char *CkSsh_httpProxyUsername(HCkSsh cHandle);

If an HTTP proxy requiring authentication is to be used, set this property to the HTTP proxy login name.

const char *CkSsh_lastErrorHtml(HCkSsh cHandle);

Error information in HTML format for the last method called.

const char *CkSsh_lastErrorText(HCkSsh cHandle);

Error information in plain-text format for the last method called.

const char *CkSsh_lastErrorXml(HCkSsh cHandle);

Error information in XML format for the last method called.

const char *CkSsh_peekReceivedText(HCkSsh cHandle, int channelNum, const char *charset);

This is the same as GetReceivedText, except the internal receive buffer is not cleared.

const char *CkSsh_sessionLog(HCkSsh cHandle);

Contains a log of the messages sent to/from the SSH server. To enable session logging, set the KeepSessionLog property = true. Note: This property is not a filename -- it is a string property that contains the session log data.

const char *CkSsh_socksHostname(HCkSsh cHandle);

The SOCKS4/SOCKS5 hostname or IPv4 address (in dotted decimal notation). This property is only used if the SocksVersion property is set to 4 or 5).

const char *CkSsh_socksPassword(HCkSsh cHandle);

The SOCKS5 password (if required). The SOCKS4 protocol does not include the use of a password, so this does not apply to SOCKS4.

const char *CkSsh_socksUsername(HCkSsh cHandle);

The SOCKS4/SOCKS5 proxy username. This property is only used if the SocksVersion property is set to 4 or 5).

const char *CkSsh_version(HCkSsh cHandle);

A version string such as "2.1.0". This indicates the version of the Chilkat component.