To be able to read the welcome message from the SSH shell, you have two possibilities:
1) if you know the prompt of the server, you can use Ssh object's StartShell method, supply the expected Prompt and then you will be able to read the welcome message like this:
Ssh ssh = new Ssh();
ssh.Connect("server", 22);
ssh.Login("username", "password");
Shell shell = ssh.StartShell(ShellMode.Prompt);
shell.Prompt = "expected_prompt ";
string welcome = shell.ReadAll();
Console.WriteLine(welcome);
2) if you do not know the prompt of the server in advance you can take advantage of the StartVirtualTerminal method and the VirtualTerminal class. You would have to Process the data comming from the SSH server for a constant amount of time (depending on your possibilities and requirements) as in the following code:
Ssh ssh = new Ssh();
ssh.Connect("server", 22);
ssh.Login("username", "password");
var terminal = ssh.StartVirtualTerminal();
var welcome = GetWelcomeMessage(terminal, 3 * 1000);
Console.WriteLine(welcome);
private string GetWelcomeMessage(VirtualTerminal terminal, int milliseconds)
{
int start = Environment.TickCount;
string data = string.Empty;
while (terminal.Process(milliseconds) == TerminalState.DataReceived)
{
data += terminal.ReceivedData;
milliseconds -= Environment.TickCount - start;
if (milliseconds <= 0)
break;
}
// remove last line which is only the server's prompt
int idx = data.LastIndexOf('\n');
if (idx > 0)
data = data.Substring(0, idx);
return data;
}