For example in the code:
Code: Select all
MySqlConnection conn = new MySqlConnection("User Id=root;Password=root;Host=localhost;Port=3306;Database=test;");
conn.ConnectionTimeout = 300;
conn.Protocol = MySqlProtocol.Ssh;
conn.SshOptions.AuthenticationType = SshAuthenticationType.Password;
conn.SshOptions.Host = "testHost";
conn.SshOptions.Port = 22;
conn.SshOptions.User = "testUser";
conn.SshOptions.Password = "test";
// sets host key verification options
conn.SshOptions.StrictHostKeyChecking = true;
conn.SshOptions.HostKey = @"D:\Test\HostKey.pub"; // file with incorrect key
conn.SshHostKeyConfirmation += new SshHostKeyConfirmationHandler(conn_SshHostKeyConfirmation);