1

I am using Tamir.SharpSSH to make SFTP connections. I have servers' host, port, username, password and servers' fingerprint.

I am able to connect to the server without the fingerprint. Is there any way to match the fingerprint that I have with the servers' before making the connection?

Following is my C#.Net code for the connection:

 Sftp sftp = new Sftp(serverHost, userName, password);
 try
 {
      if (portNumber > 0) sftp.Connect(portNumber);                
      else sftp.Connect();
      sftp.Put(localFullFilePath, remoteFolder);                
 }
4

1 回答 1

0

您是否尝试过使用 known_hosts 文件?我已经使用下面的代码解决了这个问题。

var jsch = new JSch();
var sr = new StreamReader(File.Open(@".\known_hosts", FileMode.Open));
jsch.setKnownHosts(sr);
var session = jsch.getSession("user_name", "host");
var sftp = session.openChannel("sftp") as ChannelSftp;
于 2014-08-06T12:47:03.523 回答