0 votes
by (120 points)
edited

I am trying to make a connection prior to buying this component for our company. The server is rejecting our Public Key. Here is a snippet of the code and the login call.

Do we need to do anything special to register the key on the client machine?

Any advice would be hugely appreciate else we will need to go different route for SFTP component.

        Dim Parameters As New SshParameters()
        Parameters.KeyExchangeAlgorithms = SshKeyExchangeAlgorithm.DiffieHellmanGroup1SHA1

        client.Connect(txtSftpServer.Text, 22, Parameters)

        ' change the log path if needed
        client.LogWriter = New Rebex.FileLogWriter("c:\temp\log.txt", Rebex.LogLevel.Debug)

        ' verify the server's fingerprint here unless using the event handler
        Dim fingerprint As String
        fingerprint = client.Fingerprint()


        Dim privateKey As New SshPrivateKey("\PrivateKey", "")

        client.Login("rmst", privateKey)


        ' change the log path if needed
        client.LogWriter = New Rebex.FileLogWriter("c:\temp\log.txt", Rebex.LogLevel.Debug)
Applies to: Rebex SFTP

1 Answer

0 votes
by (144k points)
edited

You don't need to register the public or private key on the client machine. Loading it into SshPrivateKey object and supplying that to Sftp object's Login method is all you need to do at the client side.

If this doesn't work, the problem is caused by something else – it looks like the key was rejected by the server. The most likely cause of this is that the public key corresponding to your private key was not set up properly at the server side. Would it be possible to verify that?

To make sure the problem is not caused by Rebex SFTP, please try connecting using a third-party SFTP client such as WinSCP or PuTTY's psftp utility (both are free) using the same private key. Does it work?

...