fail to connect by public key - WeOnlyDo Discussion board

fail to connect by public key (wodSFTP / wodSFTP.NET / wodSFTPdll)

by simonasuciu, Tuesday, January 17, 2017, 14:38 (2649 days ago)

Hello,
A use wodkey to generate a pair of ssh public-private key and wodsftp to connect to a ssh server in a Visual C++ application.
The code is like that:


IKeysPtr pKeys;

handle =Sftp_Create(pmystruct,"***wod license****");
Sftp_SetBlocking(handle, 1);
Sftp_SetHostname(handle, (char *) pszDest);
Sftp_SetLogin(handle, (char *) pszUname);
Sftp_SetPort(handle, 22);
int k = SFTPManageKeys();
long auth = Sftp_SetAuthentication(handle, AuthenticationsEnum::authPubkey);
long i = Sftp_SetPrivateKey(handle, (char*)pKeys->GetPrivateKey(SSHKeyTypes::RSAkey),2048);
i = Sftp_Connect(handle);
.....

int SFTPConnection::SFTPManageKeys()
{
SSHKeyTypes ktype = RSAkey;
...
hr = pKeys.CreateInstance (CLSID_Keys, NULL);
.....
if (fileop == 0) // file not exist
{
try
{
VARIANT var;
var.vt = VT_ERROR;
pKeys->Generate(ktype, var);
pKeys->Save(ktype, fname, var);
pKeys->PublicKeySave(ktype,fNameClient);
}
catch(CException* pe){
AfxMessageBox(_T("Error"));
pe->ReportError();
}
}
else // Load
{
pKeys->Load(fname);
}//Load

return 0;
}
I pasted the public key created by Generate method on .ssh/authorized_keys file on the server.
The problem is that the connection fails with return code 30015 and in the log file of sshd service on the server I can see the folowing :
"sshd[15204]: userauth_pubkey: unsupported public key algorithm: password ""
could you tell me the reason of this failure?
Thank you!


Complete thread: