0 votes
by (280 points)

Hi,

I am using rebex dll versision 2.0.5584.0 for SFTP conncetion. I am successfully login with username and password. But when I try to login with username and privateKey I am getting the below exception.

No suitable authentication method is supported. Supported methods: 'password,keyboard-interactive'.

Please below code:

SshPrivateKey privateKey = null;
privateKey = new SshPrivateKey(ppkFilename, password);
var sftp = new Sftp();
sftp.Connect(hostName);
ftp.Login(username, privateKey); //Here I am getting error.

I am using Rebex Tiny SFTP Server v.1.03.
Please help.

Applies to: Rebex SFTP

1 Answer

+1 vote
by (73.5k points)
selected by
 
Best answer

It seems that the server has Public key authentication disabled.

In case of Rebex Tiny SFTP Server you can enable Public key authentication as follows:

1) In "RebexTinySftpServer.exe.config" file, specify value for userPublicKeyDir key. E.g.

<add key="userPublicKeyDir" value="keys"/>

2) Create specified folder keys in server's running directory.
3) Generate private key and save both private and public keys at the disk. Using Rebex component like this:

var pk = SshPrivateKey.Generate();
pk.Save("user1.pri", "password", SshPrivateKeyFormat.OpenSsh);
pk.SavePublicKey("user1.pub", SshPublicKeyFormat.Ssh2Base64);

4) Copy "user1.pub" file into "keys" directory created in step 2.
5) Start the server, you should see in log message like this: "Public key authentication enabled."

Now the server has Public key authentication enabled and you should be able to authenticate using "user1.pri" file created in step 3.

by (280 points)
I followed same steps but still I am getting same error. I am able login with ftp.Login(username, password, privateKey) and
ftp.Login(username, password);
but still not  able to login with

ftp.Login(username, privateKey);

Please help
by (73.5k points)
Do you see "Public key authentication enabled." message in server's log?
If not, you configure the server incorrectly.

If yes, and it is still not working, please post here debug log. It can be produced like this:

using (var sftp = new Sftp())
{
    sftp.LogWriter = new FileLogWriter(@"c:\data\sftp.log", LogLevel.Debug);               
    sftp.Connect("localhost", 22);
    sftp.Login("tester", new SshPrivateKey(@"c:\data\user1.pri", "password"));
}
by (280 points)
Hi Lukas,

I didn't get "Public key authentication enabled." message. Please find the logs,

2017-06-05 01:06:05.225 Opening log file.
2017-06-05 01:06:05.225 Using FileLogWriter version 2.0.5584.0.
2017-06-05 01:06:08.226 DEBUG Sftp(1)[6] SSH: Allowed authentication methods: password, keyboard-interactive.
2017-06-05 01:06:08.320 ERROR Sftp(1)[6] SSH: Rebex.Net.SshException: No suitable authentication method is supported. Supported methods: 'password,keyboard-interactive'.
   at Rebex.Net.SshSession.KZ(String A, String B, SshPrivateKey C, SshGssApiCredentials D)

Please let me know if I missed something.
by (73.5k points)
If you didn't get "Public key authentication enabled." message, you didn't set up the server correctly.

Please download configured version from http://www.rebex.net/getfile/07eb15eb400d4d6a8b59d5160c5fe37f/RebexTinySftpServer-KeyAuthSample.zip

The .zip contains user1.pri file. Save it to e.g. "c:\data" directory and use it for Public key authentication like this:

sftp.Login("tester", new SshPrivateKey(@"c:\data\user1.pri", "password"));
by (280 points)
I solved the issue. Thanks.
...