Choose the right channel
TElSimpleSSHClient supports several operation modes implemented by different SSH channels. Depending on its configuration, it can open either a shell channel, a command channel or a subsystem channel.
You normally open the shell channel to establish an interactive terminal session to the server and run commands through it. Locally this is often represented by a terminal screen. All the data typed in such terminal is sent over the secure channel to the server, which redirects it to the real shell process (its STDIN port). All the data produced by the server-side shell process is routed securely back to the client, which displays it on the local terminal.
Command channels are quite similar to the shell channels. The only difference is that you open a single command instead. When the command terminates (either successfully or due to error), the channel is closed immediately. The command channel allows you to remove any shell-specific interaction from the scheme and communicate to the particular program directly. You can sometimes emulate a shell channel over a command channel by running the 'cmd' command.
Subsystem channels make SSH extensible as they allow to tunnel custom application data over the same secure SSH channel. Each subsystem is identified by its name and can be used to transfer data of any kind, known to the client and server. One well-known example of a subsystem is SFTP, where file protocol data is routed between the SFTP client plugged in to the SSH client and SFTP server plugged in to the SSH server. You are free to implement your own subsystem and send your own data, but you need to ensure that it's supported ('known to') by both client and server and that its name is unique and doesn't conflict with other subsystems.
In default configuration TElSimpleSSHClient operates in shell mode. You can switch it to command mode by assigning the name of the command to the Command property. Alternatively, you can add as many commands as you want to the Commands list; in this case the component will execute them in order, which is subsequent command starting after the preceding one terminates. You can track the moment when a new command starts with OnSendCommandRequest event.
By assigning a non-empty string to Subsystem property you turn the component to subsystem mode.
Note that Subsystem property has precedence over Command/Commands properties. In other words, if both Subsystem and Command are assigned, a subsystem mode will be activated.
There is also a simplified 'execute command' mode for very simple and non-interactive scenarios. ExecuteCommand() method encapsulates all the I/O functionality, including connection, disconnection and send-receive loop. This is an easy option for non-interactive commands which allows you to run server-side commands quicker and don't bother with sending and receiving data and connectivity issues.