TinySftpServer throws does not load user public key

0 votes
asked Nov 17, 2016 by sstyskin (120 points)

I've downloaded TinySftpServer C# sample, and when the server starts and tries to load users public keys, which are open ssh, I get an error:
User public key 'C:\Keys\public\pubOpenSsh.key' could not be loaded: Data too long.

Please advise.

Applies to: Rebex SFTP

1 Answer

0 votes
answered Nov 18, 2016 by Lukas Pokorny (85,590 points)
edited Nov 18, 2016 by Lukas Pokorny

How does the public key file look like?

We support two formats - a raw binary format, and a Base64-encoded format that looks like this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20161118"
AAAAB3NzaC1yc2EAAAABJQAAAQEAwAdg3eizKcQ5INIMJOL3mIkRbv5QR6uQAdpM
dBr3AZOVdhJUs76/JXbDqvJJGI5s29Bp0pnAhgTA8FZAjE63lGq7/t1Ovzjt0RDD
4IT+9fRXTye+CCHpN1vcYmiQcFzkyS6qyxTrSumP2zsGPczi9DVMoRXqPV2/10g9
8531mJFMed28zl5AK5lSUQQN5b1LIINYf89OUxB8ElObJGowQlHelNtH/2PAN9tF
0dfLlUIewRhHM6zLoIo5JvXtn/QQcP/+za/zHe6zgOhwvG/QS7Cz1z7uuNzwKund
2GadgpcAjLOWavMXncZKofRP/7vAgGpT9AER41y3vcGqfTUbXQ==
---- END SSH2 PUBLIC KEY ----

(The raw binary format is equivalent to Base64-decoded form of the encoded public key.)

If your public key is using any other format, could you please post it here or mail it to support@rebex.net?

commented Nov 18, 2016 by sstyskin (120 points)
Hi, I'm using the following format:
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAxmZNRUgGlZCp39dzNeYyQxXhx/+dHZaVqvRjDQvBSW4FX0nkCRvM6f96FpW0bg7wBA81lLzPvxlKmHt8/Mr9xbcClGwaumXBbXRy/j04BOVIMZrQ7VchG2BvqSDsHunTCaPNYIO3mDA5qQYNc2uWOkErVGmSXmklb4FCdk3/OZ1dDmMR94xYmVxdx6cNwLLlErG1P/xvVGdaiyEFh0B7CWVNjlQmzTN3e1S60Ceeb+aHoxffiQeUoJJaR+ye4j5EBvGbnXbEY4DKe6u4u0LnBSj9gswtjZFTEdGl0zXXNODea4XeqbWejyw9dp9uTaQ7kMmyIzyjsD9ZwGPvmpkhOw== rsa-key-20161117
commented Nov 18, 2016 by Lukas Pokorny (85,590 points)
This format can be converted to a supported one manually using a text editor by splitting the value and adding header and footer. Please try this:

---- BEGIN SSH2 PUBLIC KEY ----
Comment: rsa-key-20161117
AAAAB3NzaC1yc2EAAAABJQAAAQEAxmZNRUgGlZCp39dzNeYyQxXhx/+dHZaVqvRj
DQvBSW4FX0nkCRvM6f96FpW0bg7wBA81lLzPvxlKmHt8/Mr9xbcClGwaumXBbXRy
/j04BOVIMZrQ7VchG2BvqSDsHunTCaPNYIO3mDA5qQYNc2uWOkErVGmSXmklb4FC
dk3/OZ1dDmMR94xYmVxdx6cNwLLlErG1P/xvVGdaiyEFh0B7CWVNjlQmzTN3e1S6
0Ceeb+aHoxffiQeUoJJaR+ye4j5EBvGbnXbEY4DKe6u4u0LnBSj9gswtjZFTEdGl
0zXXNODea4XeqbWejyw9dp9uTaQ7kMmyIzyjsD9ZwGPvmpkhOw==
---- END SSH2 PUBLIC KEY ----

We will consider adding support for OpenSSH's ~/.ssh/authorized_keys format as well in one of the future releases.
commented Nov 23, 2016 by sstyskin (120 points)
Thanks. Any ideas when you could support open ssh format?
commented Nov 25, 2016 by Lukas Pokorny (85,590 points)
No promises on this, but it sounds quite useful. It will most likely make it into the release following the next one.
...