Discuss this help topic in SecureBlackbox Forum
SSH: Implement Command channel in the SSH server
Command channels, while being a separate class of entities as per the SSH standard, are very similar in their nature to shell channels from the SSH server implementer's viewpoint. Just like with a shell, executing a command involves creation of a local (to the server) process and redirecting its STDIN, STDOUT and STDERR channels over the connection. You can even emulate the shell channel over the command channel by invoking the shell 'manually' (by running a 'cmd' command).
Therefore most of the instructions given for shell channels are also appropriate for the command channels. The only differences are the following:
C#:
private void m_SSHServer_OnOpenCommand(object Sender, TElSSHTunnelConnection Connection, string Command)
{
TElSSHSubsystemThread thread = new TElSSHSubsystemThread(new TElShellSSHSubsystemHandler(Connection, true), Connection, true);
((TElShellSSHSubsystemHandler)(thread.Handler)).Command = Command;
thread.Handler.OnUnsafeOperationStart += new TNotifyEvent(Handler_OnUnsafeOperationStart);
thread.Handler.OnUnsafeOperationEnd += new TNotifyEvent(Handler_OnUnsafeOperationEnd);
thread.Resume();
}
You are always free to implement your own command handler for advanced scenarios not covered by TElShellSSHSubsystemHandler.