SSh with dotconnect. Exporting the ssh host key

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Posts: 124
Joined: Tue 19 Feb 2008 19:12

SSh with dotconnect. Exporting the ssh host key

Post by KW » Tue 06 Jul 2010 23:34

Can someone help me understasnd the difference between the host key and the fingerprint?

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\"; // file with incorrect key 
    conn.SshHostKeyConfirmation += new SshHostKeyConfirmationHandler(conn_SshHostKeyConfirmation); 
How do you go about correctly exporting the HostKey from your server? Do you just copy the from the server? Or do you just need to generate the fingerprint? And if so what is the correct way to get the fingerprint from your server to your client?

Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 08 Jul 2010 15:58

Yes, you are right: - is a file that contains a public part of host key. You can copy this file from your server and pass it in connection string. When establishing connection to the SSH server, dotConnect for PostgreSQL obtains the public host key from the SSH server and compares it as a byte array with the public host key provided in the connection string. If verification during establishing connection failed, the SshHostKeyConfirmation event occurs, and you can handle this event by providing fingerprints to your user with a confirmation request for establising connection.
For more information and sample, please refer to ... cking.html.

Post Reply