Topic "Host key wasn't verified"

Author Message
okeskiner
[View user's profile]

Joined: 2013-05-02
Posts: 1
Location: istanbul
Hello I copied sample code from your tutorial, I create a console application in visual studio
I added your assembly to my references

Code:
static void Main(string[] args)
        {
            try
            {
                // Setup session options
                SessionOptions sessionOptions = new SessionOptions
                {
                    Protocol = Protocol.Sftp,
                    HostName = "xx.xx.com",
                    UserName = "xxx",
                    PortNumber = 19321,
                   
                    SshHostKeyFingerprint = "ssh-rsa 1024 a4:9b:a5:8f:fb:a0:b8:10:8d:28:44:e7:82:24:df:68",
                    SshPrivateKeyPath = ("C:\\Users\\okeskiner\\Desktop\\id_dsa.ppk")

                   
                   
                   
                   
                };

                using (Session session = new Session())
                {

               
                    // Connect
                    session.Open(sessionOptions);

                    // Upload files
                    TransferOptions transferOptions = new TransferOptions();
                    transferOptions.TransferMode = TransferMode.Binary;

                    TransferOperationResult transferResult;
                    transferResult = session.PutFiles(@"c:\bideneme\*", "/test/", false, transferOptions);

                    // Throw on any error
                    transferResult.Check();

                    // Print results
                    foreach (TransferEventArgs transfer in transferResult.Transfers)
                    {
                        Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
                    }
                }

               // return 0;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e);
              //  return 1;
            }
            Console.ReadKey();
        }


As a matter of fact if I try this key with winscp sftp client, there's nothing wrong, I'm successfully logged in server. There's a page https://www.linode.com/docs/tools-reference/file-transfer/transfer-files-with-winscp-on-windows/ about sftp winscp client tutorial , but if I try with this sample code it gives error
------------------------------------------------------------------------------------------
Code:
Error: WinSCP.SessionRemoteException: Host key wasn't verified! ---> WinSCP.Sess
ionRemoteException: Host key fingerprint is ssh-dss 1024 28:47:22:31:c8:36:04:db
:31:0d:80:ec:9b:e3:49:c0.
Authentication failed.
   --- End of inner exception stack trace ---
   at WinSCP.SessionLogReader.Read(LogReadFlags flags)
   at WinSCP.ElementLogReader.Read(LogReadFlags flags)
   at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogRead
Flags flags)
   at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFla
gs flags)
   at WinSCP.CustomLogReader.WaitForNonEmptyElementAndCreateLogReader(String loc
alName, LogReadFlags flags)
   at WinSCP.CustomLogReader.WaitForGroupAndCreateLogReader()
   at WinSCP.Session.Open(SessionOptions sessionOptions)
   at Youtubevideouploadapi.Program.Main(String[] args) in c:\Users\okeskiner\Do
cuments\Visual Studio 2012\Projects\WebApplication\Youtubevideouploadapi\Program
.cs:line 35


How can I solve this problem?
Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24993
Location: Prague, Czechia
Well, you obviously use wrong key:

okeskiner wrote:
SshHostKeyFingerprint = "ssh-rsa 1024 a4:9b:a5:8f:fb:a0:b8:10:8d:28:44:e7:82:24:df:68",

Quote:
Error: WinSCP.SessionRemoteException: Host key wasn't verified! ---> WinSCP.Sess
ionRemoteException: Host key fingerprint is ssh-dss 1024 28:47:22:31:c8:36:04:db
:31:0d:80:ec:9b:e3:49:c0
.

_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License