SSH Implementation

SSHImpl is a component which implements the secure shell protocol.

Creating a SSH implementation component:

ssh = new TSSHImpl();

Example:

ssh = new TSSHImpl(); ssh.Timeout = 4000; ssh.User = 'root'; ssh.Pass = 'secret'; ssh.Host = '192.168.0.125'; ssh.Port = 22; if(!ssh.Connect()){ LogError(ssh.LastError); Exit(); } if(!ssh.Send('ls /')){ LogError(ssh.LastError); Exit(); } if(ssh.LoggedIn){ Trace(ssh.Receive()); ssh.Send('ls /'); Trace(ssh.Receive()); } ssh.Close();

Functions:

Properties:

function Connect()

Try to connect to SSH server with the supplied username and password.

Return values:

Connect will return boolean true on successfull connect or false if an error happens. When return value is false, LastError will contain the description of the error.

function Receive()

Receive data from the SSH connection.

Return values:

Receive returns a string value with the data received or an empty string on error. In the later case LastError should contain the error description.

function Close()

Closes the SSH connection.

function Send(Text)

Sends a string to the server.

Parameter list:

Return values:

Receive returns a boolean value. True indicates success and false failure. In the later case LastError should contain the error description.

property SshVersion

Read only integer value representing version of SSH protocol negociated on connect. Possible values are:

property EncryptionAlgorithmClientToServer

Read only integer property representing the algorithm, negociated during SSL handshake, which will be used by the client to encrypt communication data. Possible values are:

property EncryptionAlgorithmServerToClient

Read only integer property representing the algorithm, negociated during SSL handshake, which will be used by the server to encrypt communication data. Possible values are the same as for EncryptionAlgorithmClientToServer.

property MacAlgorithmClientToServer

Hash algorithm negociated on connect used by the client.

property MacAlgorithmServerToClient

Hash algorithm negociated on connect used by the server.

property PublicKeyAlgorithm

Read only integer property specifying the public key algorithm that was used during the SSH handshake. Possible values are:

property ServerKeyFingerprint

Read only string property representing the MD5 hash of the server's public key.

property LastError

Read only string property with the error details of the last unsuccessful operation.

property User

Read and write string property representing the username to be used on login.

property Pass

Read and write string property representing the password to be used on login.

property Host

Read and write string property representing the host, script should connect to.

property Port

Read and write integer property representing the port of the host, script should connect to.

property Timeout

Read and write integer property representing the number of milliseconds after which an operation is considered unsuccessful. If this value is 0 operations will not be timeouted.

property LastStdError

Read only string property which after a Receive operation contains last data string from stderr.

property Active

Read only boolean value indicating the state of the connection. Value true means the client is connected.

property LoggedIn

Read only boolean value containing true if client has successfully connected or false if the authentication was unsiccessful.