0 votes
by (120 points)
edited

What can cause the Message "Invalid Key Format" if I do this:

Using oClient As New Sftp()

        Try
            oClient.Connect(Me.Server)
            If Not String.IsNullOrEmpty(Me.KeyFile) Then
                Me.m_privateKey = New SshPrivateKey(System.Text.Encoding.Default.GetBytes(Me.KeyFile), Me.Passphrase)

                If String.IsNullOrEmpty(Me.Passwort) Then
                    oClient.Login(Me.Benutzer, Nothing, Me.m_privateKey)
                Else
                    oClient.Login(Me.Benutzer, Me.Passwort, Me.m_privateKey)
                End If

            Else
                oClient.Login(Me.Benutzer, Me.Passwort)
            End If

        Catch ex As Exception
            oClient.Disconnect()
            Fehler = ex.Message
            Return False
        End Try
    End Using
by (144k points)
This message is thrown when Rebex SFTP can't parse a Base64-encoded key file. Would it be possible to send one of these keys to us for analysis? If you can't, try opening the key file with notepad and let us know what lines are at the beginning and the end - that might be sufficient to be able to tell what is going on.

1 Answer

0 votes
by (144k points)
edited

This message is thrown when Rebex SFTP can't parse a Base64-encoded key file. Would it be possible to send one of these keys to us for analysis? If you can't, try opening the key file with notepad and let us know what lines are at the beginning and the end - that might be sufficient to be able to tell what is going on.

Alternatively, if you are able to use this key in third-party application, please download PuTTY "puttygen" utility. Try loading or importing the key into it and then save it in PuTTY or OpenSSH format. Once saved, you should be able to use the key in Rebex SFTP.

...