SSH host key fingerprint does not match pattern C# WinSCP -
i trying connect ftps server using c# via winscp , getting error:
ssh host key fingerprint ... not match pattern ...
after tons of research, believe has length of key. key got winscp when connected using interface under "server , protocol information" xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx ones saw in example shorter xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
can please , offer me pointer resolve appreciated.
here code
string winscppath = "c:\\program files (x86)\\winscp\\winscp.exe"; string username = "user123"; string password = "abc1234"; string ftpsite = "192.168.5.110"; string localpath = "c:\\users\\ttom\\documents"; string remoteftpdirectory = "/usr/thisfolder"; string sshkey = "1b:68:10:80:77:c6:65:91:51:31:5t:65:1c:g6:13:20:39:g8:d8:6d"; boolean winscplog = true; string winscplogpath = "c:\\users\\ttom\\documents\\visual studio 2015\\projects\\webapplication1\\webapplication1"; sessionoptions sessionoptions = new sessionoptions { protocol = protocol.sftp, hostname = ftpsite, username = username, password = password, sshhostkeyfingerprint = sshkey }; using (session session = new session()) { // winscp .net assembly must in gac used ssis, // set path winscp.exe explicitly, if using non-default path. session.executablepath = winscppath; session.disableversioncheck = true; if (winscplog) { session.sessionlogpath = @winscplogpath + @"ftplog.txt"; session.debuglogpath = @winscplogpath + @"debuglog.txt"; } // connect session.timeout = new timespan(0, 2, 0); // 2 minutes session.open(sessionoptions); transferoptions transferoptions = new transferoptions(); transferoptions.transfermode = transfermode.binary; session.getfiles(remoteftpdirectory + "/" + "test.txt", localpath, false, transferoptions); }
you connecting using sftp (over ssh) in code, using ftps (ftp on tls/ssl) in gui.
these 2 completely different protocols.
use protocol = protocol.ftp , enable tls/ssl using ftpsecure = ftpsecure.explicit.
sessionoptions sessionoptions = new sessionoptions { protocol = protocol.ftp, ftpsecure = ftpsecure.explicit, hostname = ftpsite, username = username, password = password, }; an equivalent of sshhostkeyfingerprint ftps tlshostcertificatefingerprint. need use when tls/ssl certificate not signed trusted authority (e.g. self signed certificate).
the easiest 5.8.x (beta currently) , use generate code function. can use generated code stable version of winscp .net assembly.

Comments
Post a Comment