Merhaba,

Nerede hata yaptınız tam olarak bilemiyorum ama bağlantı kodunu belirttiğiniz şekilde paylaşıyorum.

Teşekkürler.

public partial class Form1 : Form
    {
        static SshExec exec;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Bağlan")
            {
                    try
                    {

                        exec = new SshExec(textBox1.Text, textBox2.Text, textBox3.Text);
                        exec.Connect(int.Parse(textBox4.Text));

                        if (exec.Connected == true)
                        {
                            MessageBox.Show("Bağlantı kuruldu");
                            button1.Text = "Bağlantıyı Kes";
                        }

                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
             }

            else if (button1.Text == "Bağlantıyı Kes")
            {
                if (exec.Connected == true)
                {
                    exec.Close();
                    button1.Text = "Bağlan";
                }
            }
            
        }
    }