public bool Connect()
{
System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: connecting ....");
try
{
ConnectionInfo info = new PasswordConnectionInfo(_host,_port, _user, _pw);
_client = new SshClient(info);
_client.ErrorOccurred += SSHError;
_client.Connect();
_stream = _client.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: connected");
return true;
}
catch (System.Exception e)
{
System.Diagnostics.Debug.WriteLineIf(DEBUG, "ssh: error while connecting:");
System.Diagnostics.Debug.WriteLine(e.Message);
System.Diagnostics.Debug.WriteLine(e.InnerException);
return false;
}
}
public bool Connect(string host, ushort port, string user, string pw) { if (!_connected && !_disconnecting) { _sendQueue.Clear(); _receiveQueue.Clear(); _rsConnector = new RSSSHConnector(this, host, port, user, pw); if (_rsConnector.Connect()) { _rsProtoBuf = new RSProtoBuf(_rsConnector.Stream, _sendQueue, _receiveQueue, this); _connected = true; _run = true; _t = new Thread(new ThreadStart(ProcessNewMsgLoop)); _t.Name = "Process new msg loop"; _t.Priority = ThreadPriority.Normal; _t.Start(); return(true); } } return(false); }