How can i get Host Fingerprint algorith.

Dec 21, 2012 at 8:11 AM

I'm using SFTP. I found a very nice event.... "HostKeyReceived". With it I can read the fingerprint. Most common using algorith is SSH-RSA. But what if its a different one?

I found the part of the code that contain the name of the key.

...Renci.SshClient\Renci.SshNet\Common\HostKeyEventArgs.cs

it would be nice, if this code will take into the repository. to know the algorithm name is really nice feature.

 

    /// <summary>
    /// Provides data for the HostKeyReceived event.
    /// </summary>
    public class HostKeyEventArgs : EventArgs
    {
        /// <summary>
        /// Gets or sets a value indicating whether host key can be trusted.
        /// </summary>
        /// <value>
        ///   <c>true</c> if host key can be trusted; otherwise, <c>false</c>.
        /// </value>
        public bool CanTrust { get; set; }

        /// <summary>
        /// Gets the host key.
        /// </summary>
        public byte[] HostKey { get; private set; }

        /// <summary>
        /// Gets the finger print.
        /// </summary>
        public byte[] FingerPrint { get; private set; }

        /// <summary>
        /// Gets the length of the key in bits.
        /// </summary>
        /// <value>
        /// The length of the key in bits.
        /// </value>
        public int KeyLength { get; private set; }

        /// <summary>
        /// Algorithm name
        /// </summary>
        public String Name { get; private set; } ///new part

        /// <summary>
        /// Initializes a new instance of the <see cref="HostKeyEventArgs"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public HostKeyEventArgs(KeyHostAlgorithm host)
        {
            this.CanTrust = true;   //  Set default value

            this.HostKey = host.Data;

            this.Name = host.Name; ///new Part

            this.KeyLength = host.Key.KeyLength;

            using (var md5 = new MD5Hash())
            {
                this.FingerPrint = md5.ComputeHash(host.Data);
            }
        }
    }

Coordinator
Dec 21, 2012 at 2:11 PM

Hi,

 

Please check latest source code where I added HostKeyName property to HostKeyEventArgs.

 

Thanks,

Oleg

Dec 21, 2012 at 2:51 PM

Thanks....