Public Key Authentication with C++ Builder 6 (wodSSH / wodSSH.NET)
Posting this to the forum in case the answer helps others in the future.
I'm struggling to authenticate with an OpenSSH server (Windows XP) using public key authentication. I can authenticate with the server using Putty, but I receive the error key not found when using wodSSH (I can also authenticate using password authentication - either through Putty or wodSSH). I think the problem may lie in the retrieval of the Private Key - since when its returned as a WideString the first few characters are NULL. If you retrieve it as a SAFEARRAY then an authentication attempt actually takes place, but still fails.
Here is my code:
if(!ClientKey) ClientKey = new TKeys(NULL);
WideString Filename = c:\program files\openssh\etc\TestKey ;
if(FileExists(Filename))
{
ClientKey->Load(Filename);
}
else
{
ClientKey->Generate(Wodsshkeylib_tlb::RSAkey);
ClientKey->Save(Wodsshkeylib_tlb::RSAkey, Filename);
}
if(!Client) Client = new TwodSSHCom(NULL);
Client->set_Protocol(Wodsshcomlib_tlb::SSHAuto);
Client->set_Hostname(WideString( localhost ));
Client->set_Authentication(Wodsshcomlib_tlb::authPubkey);
// Using the get_PrivateKey method simply causes it to hang,
// whereas this will actually 'attempt' to authenticate.
SAFEARRAY *PrivateKey = ClientKey->get_PrivateKeyData
(Wodsshkeylib_tlb::RSAkey);
Client->set_PrivateKey(TVariant(PrivateKey));
Client->set_Port(22);
Client->set_Blocking(true);
Client->set_Login(WideString( lucasd ));
Client->set_Password(WideString( july2005 ));
Client->OnConnected = ClientConnected;
Client->OnReceived = ClientReceived;
Client->OnLoginChallenge = ClientLoginChallenge;
Client->Connect1();
Hoping you can shed some light on what I'm doing wrong,
Regards,
David Lucas
Data Track Technology
Complete thread:
- Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-19, 12:44
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-19, 12:55
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-19, 23:35
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-21, 16:51
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-21, 17:27
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-21, 20:37
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-22, 09:45
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-22, 10:18
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-22, 11:13
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-22, 11:37
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-22, 11:13
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-22, 10:18
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-22, 09:45
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-21, 20:37
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-21, 17:27
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-21, 16:51
- Re: Public Key Authentication with C++ Builder 6 - wodSupport, 2005-07-19, 23:35
- Re: Public Key Authentication with C++ Builder 6 - David Lucas, 2005-07-19, 12:55