The SSH protocol works using channels. After we've established an SSH connection, a channel must be opened to do any real work. The advantage is that many channels can be opened over one connection. This potentially allows an application to do multiple things (seemingly) simultaneously.
After the SSH session is open and the user is authenticated, a channel can be opened. A new channel is opened by calling the ssh_channel_new() function. The following code illustrates this:
/*ssh_command.c excerpt*/
ssh_channel channel = ssh_channel_new(ssh);
if (!channel) {
fprintf(stderr, "ssh_channel_new() failed.\n");
return 0;
}
The SSH protocol implements many types of channels. The session channel type is used for executing remote commands and transferring files. With libssh, we can request a session channel by using the ssh_channel_open_session...