Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: validating fingerprint as string

$
0
0
Here's another example:
            using (var sftp = new SftpClient(host, username, password))
            {
                sftp.HostKeyReceived += (sender, e) => {

                    var knownFingerprint = "ssh-rsa 2048 5b:eb:4e:ef:ab:cd:25:2c:37:58:b6:2d:08:d5:56:12";

                    var providedFingerprint = String.Format(
                        "{0} {1} {2}",
                        e.HostKeyName,
                        e.KeyLength,
                        String.Join(":", e.FingerPrint.Select(b => b.ToString("x")))
                        );

                    e.CanTrust = knownFingerprint == providedFingerprint;
                };

                sftp.Connect(); // <- HostKeyReceived executes. If CanTrust was set to false, Connect() will throw an exception
                // ...
            }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>