Hi, How do I check fingerprint after connection?

Thanks.

asked 08 Sep '10, 20:39

ubuser's gravatar image

ubuser
16
accept rate: 0%

edited 09 Sep '10, 14:51

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519


Hi,

I guess you are asking for fingerprint checking in the sftp connection. There is a code scatch:

string hostname = "your-host-name";

// get server fingerprint
Sftp client = new Sftp();
client.Connect(hostname);
string fingerprint = client.Fingerprint;

// loading from some storage (defining is up to you)
Dictionary<string,string> approvedFingerprints = LoadApprovedFingerprints();

// check finger print
if (approvedFingerprints.ContainsKey(hostname))
{
    if (fingerprint == approvedFingerprints[hostname])
    {
        // checking OK
    }
    else
    {
        // hostname changed !
        //   if you trust: 
            //     approvedFingerprints[hostname] = fingerprint;
    }
}
else
{
    // new or disaproved hostname
    //   if you trust: approvedFingerprints[hostname] = fingerprint;
}

SaveApprovedFingerprints(approvedFingerprints);

A brief description of fingerprint checking is given in the Rebex SFTP Tutorial, Basics.

link

answered 09 Sep '10, 14:50

Vit%20Zyka's gravatar image

Vit Zyka
912
accept rate: 8%

Hi,

You showed a code that is calling LoadApprovedFingerprints() method.

Can you explain in detail? I am coding in vb.net.

At the bottom you wrote:

SaveApprovedFingerprints(approvedFingerprints);

Why do we need to do this.

Let me know.

Thanks

(09 Sep '10, 15:42) ubuser

Hi, the LoadApprovedFingerprints and SaveApprovedFingerprints are method that need to be implemented by you. It should store and load pairs of hostname-fingerprint which you trust. It's implementation is application specific. Different code would be used when storing it to the database table, to xml file or to registry. You can even provide a hard coded set of trusted fingerprints and encode it to your application.

(10 Sep '10, 09:29) Martin Vobr ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×141
×20

Asked: 08 Sep '10, 20:39

Seen: 719 times

Last updated: 09 Sep '10, 14:51