private void LocalVmToolStripMenuItemClick(object sender, EventArgs e)
{
var connectionInfo = new PasswordConnectionInfo(host, 22, username, password);
connectionInfo.AuthenticationBanner += ConnectionInfoAuthenticationBanner;
connectionInfo.PasswordExpired += ConnectionInfoPasswordExpired;
sshClient = new SshClient(connectionInfo);
sshClient.ErrorOccurred += SshClientErrorOccurred;
Log(string.Format("Connecting to {0}:{1} as {2}", connectionInfo.Host, connectionInfo.Port, connectionInfo.Username));
try
{
sshClient.Connect();
var tunnel = sshClient.AddForwardedPort<ForwardedPortLocal>("localhost", 20080, "www.google.com", 80);
tunnel.Start();
}
catch (Exception ex)
{
Log(ex.ToString());
}
finally
{
sshClient.Dispose();
}
Log("Connected");
sshClient.ForwardedPorts.ToList().ForEach(p => Log(string.Format("SSH tunnel: {0}:{1} --> {2}:{3}", p.BoundHost, p.BoundPort, p.Host, p.Port) ));
}