It depends on format your public key is saved. Rebex supports the SSH2 public key format (binary or base64-encoded).
To load a public key, just use a constructor of the SshPublicKey
class:
// the constructor automatically recognizes between the binary and the base64-encoded format
var key = new SshPublicKey(@"c:\temp\server.key");
Console.WriteLine(key.Fingerprint);
However, if you intend to use the public key just for server verifying, you don't have to keep the whole public key - keeping the fingerprint only is good enough:
Retrieve the fingerprint when first connected to the server:
client.Connect("test.rebex.net");
client.Login("demo", "password");
// remember the fingerprint for the next usage
File.WriteAllText(@"c:\temp\fingerprint.txt", client.Fingerprint);
Verify the fingerprint when connecting to the known server:
client.Connect("test.rebex.net");
client.Login("demo", "password");
// verify the current connection's fingerprint with the stored one
var storedFingerprint = File.ReadAllText(@"c:\temp\fingerprint.txt");
if (client.Fingerprint != storedFingerprint)
throw new Exception("Stored fingerprint doesn't match!");