EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Error - Invalid public key error

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#8950
Posted: 02/18/2009 06:35:41
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

OK I've just found out what I think the problem is.

Each time you assign a value to it AuthenticationTypes it basically overwrites it with the new value so effectively only the last line is valid, i.e. the one that sets SSH_AUTH_TYPE_KEYBOARD.

So I think we need to find a different way to do this?

Rob

#8951
Posted: 02/18/2009 06:50:59
by Ken Ivanov (EldoS Corp.)

Would you be so kind to specify the exact line that does not work for you?
#8952
Posted: 02/18/2009 08:10:14
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

I'm not entirely sure as they're all set up as you've already specified

SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and SSH_AUTH_TYPE_PUBLICKEY;

SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_PASSWORD;

SFtpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_KEYBOARD;

but I'm still getting the 'Authentication Type[16] failed'?
#8953
Posted: 02/18/2009 08:13:17
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

And to answer your previous question no I haven't got the keyboard-interactive authentication type enabled somewhere else in my code.
#8954
Posted: 02/18/2009 08:16:41
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

I'm not sure if this will help or not but here's the section of the code that I've been working on:

Key := TElSSHKey.Create;
if (frmConnProps.edPrivateKey.Text <> '') and FileExists(frmConnProps.edPrivateKey.Text) and
(Key.LoadPrivateKey(frmConnProps.edPrivateKey.Text, frmConnProps.editPassword.Text) = 0) then
begin
FKeyStorage.Add(Key);
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes or SSH_AUTH_TYPE_PUBLICKEY;
end
else
begin
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and SSH_AUTH_TYPE_PUBLICKEY;
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_PASSWORD;
SFtpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_KEYBOARD;
end;
#8955
Posted: 02/18/2009 08:23:56
by Ken Ivanov (EldoS Corp.)

1.
Quote
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and SSH_AUTH_TYPE_PUBLICKEY;

The bit flags should be enabled using the or operation, not the and one.

2. You are disabling other authentication flags in the else section of the conditional operator. Obviously it is not executed and the authentication types thus are not getting disabled.
#8960
Posted: 02/18/2009 10:07:22
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

Here's my code but I'm still getting Authentication Type[16] failed'?

begin
FKeyStorage.Add(Key);
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes or SSH_AUTH_TYPE_PUBLICKEY and not SSH_AUTH_TYPE_PASSWORD and not SSH_AUTH_TYPE_KEYBOARD;
end
else
begin
SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and SSH_AUTH_TYPE_PUBLICKEY;
end;

#8961
Posted: 02/18/2009 10:29:18
by Eugene Mayevski (EldoS Corp.)

Don't get me wrong but I suggest that you re-read some programming book on boolean logic. It's getting complicated to explain you the basics of it here.



Sincerely yours
Eugene Mayevski
#8965
Posted: 02/19/2009 06:33:49
by Robert Bruce (Basic support level)
Joined: 02/04/2009
Posts: 21

OK this was a bit hard to hear but you were right I did need some revision with logical bitwise manipulation! The trouble is I've been using Delphi since version 1 on and off for about 10 years and I can tell you than I've only ever seen it used a few times. I know that it does get used allot more in languages like C++.

OK regarding the Authentication types I forgot to mention that the property is initialised with the starting value of 22. At the end of each line of my code that you said I needed I've added a comment to say what value of the result of the of bitwise manipulation is

SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes or SSH_AUTH_TYPE_PUBLICKEY; //22

SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_PASSWORD; //18

SftpClient.AuthenticationTypes := SftpClient.AuthenticationTypes and not SSH_AUTH_TYPE_KEYBOARD; //2

Effectively I could've commented out the first and it wouldn't have made any difference to the value of the AuthenticationTypes final value.

Now I've made some progress as I'm no longer getting those authentication errors and it now now says 'Authentication succeeded'. But then about a minute later it says 'SFTP connection failed with message [Connection timed out (error code 10060)]?



#8966
Posted: 02/19/2009 07:02:12
by Ken Ivanov (EldoS Corp.)

Have you checked the "Allow SFTP subsystem" checkbox on the server settings dialog?
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 11562 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!