Ok, I've never programmed before so please be gentle and type very slowly when replying 
What I'm trying to do is connect to a Linux box and issue commands.
I've managed to connect to the Linux server when the "Connect" button is clicked. But how do I
1. Keep the connection open? If I click on the next tab in the form the connection closes.
2. I have to create the following variable every time.
Thank you in advance for any replies.

What I'm trying to do is connect to a Linux box and issue commands.
I've managed to connect to the Linux server when the "Connect" button is clicked. But how do I
1. Keep the connection open? If I click on the next tab in the form the connection closes.
2. I have to create the following variable every time.
Code:
SshExec exec = new SshExec(ip_textbox.Text, username_textbox.Text, password_textbox.Text);
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tamir.SharpSsh;
namespace LMC
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void connect_button_Click(object sender, EventArgs e)
{
//Connects to server using details entered by user under logon tab
SshExec exec = new SshExec(ip_textbox.Text, username_textbox.Text, password_textbox.Text);
exec.Connect();
//If the connection is successful, it changes the connection status label
connectionstatus_label.ForeColor = Color.Green;
connectionstatus_label.Text = "Status: Connected";
}
private void ServerInfo_Tab_Click(object sender, EventArgs e)
{
//Runs a command on the server, just for testing purposes
string command;
command = "cat /etc/redhat-release";
string output = exec.RunCommand(command);
osrelease_textbox.Text = output;
}
}
}
Thank you in advance for any replies.