+2 votes
by (600 points)
retagged by

I am using Rebex Tiny SFTP Server. I am able to connect on passing username and password. Also working fine by passing username,password and privatekey.

client.Login(username,password);
client.Login(username,password,privateKey);

But issue occurs on passing username and private key.
client.Login(username,privateKey);
No suitable authentication method is supported. Supported methods: 'password,keyboard-interactive'.

Applies to: Tiny SFTP Server

1 Answer

0 votes
by (58.9k points)
edited by

Update: Private/public key authentication was released in version 1.0.2. You can download it from https://www.rebex.net/tiny-sftp-server/ and give it a try.

A beta version of Rebex Tiny SFTP server with support for private/public key authentication is already available. Please download it and give it a try.
It will be included in one of the next Tiny Sftp Server releases.

You will need to put your user's public keys into the directory specified by the 'userPublicKeyDir' value in the config file.

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

by (110 points)
I put my public key in that directory, and Tiny Rebex SFTP server prints a message that the key was loaded successfully. But when I try to connect, authentication fails.

My guess is that I need to associate the public key to a username, so when a client tries to connect, the server knows which key to use.
Could that be the problem? If so, how do I do that?

Otherwise, do you have an idea what I could bemissing?
by (2.0k points)
The server only supports one user so any public keys found are associated with the user. Just checking, does your SFTP client actually load your private key?
by (120 points)
How do I get the public key to put in the config section
by (73.6k points)
You have to use an SSH key generator to generate SSH key pair. On Linux or Win10 or higher you can use ssh-keygen command. Very popular is also PUTTYGEN.

Please note that public key can be stored in multiple formats. Let suppose you generated two files key.pub and key.pri (.pub for public key and .pri for private key).

If you've used PUTTYGEN, the public key content starts with line like this:
---- BEGIN SSH2 PUBLIC KEY ----
In this case, just simply copy the key.pub file into a location specified in the config section.

If you've used ssh-keygen, the public key content is a single line which looks like this:
ssh-ed25519 AAAA...ZEs5qu tester
In this case, copy the key.pub file into a location specified in the config section and name it authorized_keys - it is necessary in this case, because the public key is OpenSSH's authorized_keys file format.

We will add better detection of file formats, but in the current version, you have to distinct between the two cases yourself (by naming the file authorized_keys if needed).
by (120 points)
edited by
I am getting one error invalid privatekey format , but I am able to connect through external tool like filezila, my private key format is like below
getting error in the below line
 SshPrivateKey privateKey = new SshPrivateKey(@"C:\Ecom\BackUp\E-ComPvtKey.ppk");

PuTTY-User-Key-File-3: ssh-rsa
Encryption: none
Comment: rsa-key-20241118
Public-Lines: 12
AAAAB3NzaC1yc2EAAAADAQABAAACAQDWklqxlRmwk9NlTqM/xBve9ml+va4jifR+
y3DLeALAIDIDxCaC7PMD4rQ3j2006PZE0GFo2co5jP3hwFXooS9MJ7gHjgjXGOMI
XPgZG4o53MCswO+e/9xZxfYNsLJN/3C5/8GVBMTlT5E9XJlPK8fdstUtanPYDGgd
qwqwqwqwqwqwqwqwqwqwqwqwqwwqwqwwqqwwqwqwqwqwqwqwqwqwqwqwqwqwqwwq
kDzrTp/mpw==
Private-Lines: 28
wqwqwqwqwqwqwqwqwqwqwqwwqwwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwqwwqw
jl+CNpzrliEXCvcXr1RSvr5e5R0n07B/ZeVIp5KCsWDBGAs8f37PwmE8p93aoI4M
PyUp
Private-MAC: eb42f8930a22ec3974fa0aa720d8278eaf7161db3ec259a7fc7960511468517a
by (120 points)
Hi Team,
The above issue has fixed , my key was in the PPKv2 format , I have converted to openssh format then it works
by the way this issue was not regarding the Rebex tiny sftp server I just continued the chat in this list
Thanks for the support
...