0

I have a program section like this. However, I get an error on SshHostKeyFingerprint.

I don't understand what is supposed to go in here. When I use the WinSCP program and enter the credentials, everything works fine.

       var host = "sftp.xxx.xx.com";
       var uname = "auser";
       var passwd = "apasswd";

       SessionOptions sessionOptions = new SessionOptions
       {
            Protocol = Protocol.Sftp,
            HostName = host,
            UserName = uname,
            Password = passwd,
            SshHostKeyFingerprint = "ssh-rsa 2048 =@" + host
       };

       Session session = new Session();
       session.Open(sessionOptions);
Ivan
  • 7,448
  • 14
  • 69
  • 134
  • `ssh-rsa 2048 =@sftp.xxx.xx.com` doesn't look like a valid SSH host key fingerprint in the least, if you compare it [to the docs](https://winscp.net/eng/docs/message_sessionoptions_sshhostkeyfingerprint_is_not_set). – AKX May 31 '22 at 14:44
  • 1
    See "Learn to obtain host key fingerprint" here: https://winscp.net/eng/docs/library_sessionoptions – David Brabant May 31 '22 at 14:47
  • I see, but I am still confused. How come the WinSCP program itself doesn't need to do this? How does it know what the correct SSh key is? – Ivan May 31 '22 at 14:58
  • What I've experienced with WinSCP is that the first time it connects to a new server it pops up a security prompt asking if I want to add the host's fingerprint to the cache. I believe that's how it "knows". – IVSoftware May 31 '22 at 15:25
  • I figured it out thanks David Brabant – Ivan May 31 '22 at 16:42
  • See [Why does FileZilla work without knowing any keys, but WinSCP doesn't?](https://stackoverflow.com/q/12303314/850848) and many other similar questions. – Martin Prikryl May 31 '22 at 18:14

0 Answers0