0 votes
by (200 points)
edited

Hi!: I have to say that I'm a novice in SFTP programation. I'm having troubles connecting to a freeFTPd server. I'm using a private key generated with Rebex KeyGenerator_VB (PKCS #8 without Passphrase) This is my code:

...
        Dim privateKey As New SshPrivateKey("Cafe.pri", "")
        Dim fingerprnt As String = ""
        fingerprnt = client.Fingerprint.ToString
        If p_finger.ToString.Equals(fingerprnt) Then
            client.Login(p_user, p_pass, privateKey)
        End If
...

And the Login function returns this message:

"Rebex.Net.SftpException: A public key corresponding to the supplied private key was not accepted by the server or the user name is incorrect. ---> Rebex.Net.SshException: A public key corresponding to the supplied private key was not accepted by the server or the user name is incorrect. at Rebex.Net.SshSession.1QmUCN(String , String , SshPrivateKey , SshGssApiCredentials ) at Rebex.Net.SshSession.Authenticate(String userName, String password, SshPrivateKey privateKey) at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey) --- End of inner exception stack trace --- at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey) at Rebex.Net.Sftp.Login(String userName, SshPrivateKey privateKey)"

The user and password are fine, because I connect without key and I don't have any problem. And I'm using the same PrivateKey file in both sides, client and server (Cafe.pri) Could you help me, please? It's a problem with the private-key, or is the SFTP server? What I am doing wrong?

Thanx a lot in advance.

4 Answers

0 votes
by (148k points)
edited

Hi, this look like the key is not properly configured at the server. This might be the cause of the problem:

"And I'm using the same PrivateKey file in both sides, client and server (Cafe.pri)"

Where have you put the private key file at the server? Have you configured it as a server key (as in this dialog), or assigned it to the user account you are using to authenticate? In the first case, this would not enable users to use it for authentication, while in the second case, a public key (not a private key) is needed.

Please send us a screenshot showing how and you configured the server to use the key, that should make it possible to tell what is going on.

0 votes
by (200 points)
edited

Hi! Thanx a lot for your answer! The configuration is like follows:

image

I don't find any place where put a public key in server Settings. I'm using freeFTPd alone (without freeSSHd).

I must use another SFTP server? Which one do you recommend?

Thanx a lot for your help.

0 votes
by (148k points)
edited

This is the server key configuration dialog. Even if you use the same key here and for client authentication, it won't work because it's purpose is different.

I was unable to find any settings related to public keys for user authentication in freeFTPd, but I found a forum post of a user asking about this feature in 2006. It looks like it still has not been added, although freeSSHd have supported it for years.

If you like freeFTPd, try using freeSSHd instead. Otherwise, I would recommend Bitvise WinSSHD.

0 votes
by (200 points)
edited

Ok, I'm testing Bitvise WinSSHD and I don't have any problems.

Thanks a lot for your support.

...