SSH Client connection - WeOnlyDo Discussion board

SSH Client connection (wodSSHTunnel)

by Mariana Cimpoca, Timisoara, Thursday, December 15, 2016, 15:24 (338 days ago) @ Jasmine

Hi,

Here's the code, CKeys class is part of wodKeys.
I use wodSFTPdll.lib for my SSH client connection application.

#define RSAkey 0
#define DSAkey 1
#define DCSkey 2

void CSSHConnectionApp::KeyManager()
{
CKeys oKey; // Keys object
VARIANT sbitCount;

const CHAR *pPassword = "AuthenticationPassword";
vmyPassword.vt = VT_BSTR; // set to BSTR string
vmyPassword.bstrVal = SysAllocString((OLECHAR *)pPassword);

CString fNameClient= _T ("C:\\KeyValues.rsa");
CFile keyFile;

try
{
keyFile.Open((LPCTSTR)fNameClient, CFile::modeCreate | CFile::modeReadWrite);
}
catch(CFileException ex)
{
ex.ReportError();
keyFile.Abort(); // close file safely
}

try
{
sbitCount.iVal = oKey.get_BitCount(RSAkey);
oKey.Generate((long) RSAkey, sbitCount);

oKey.Save((long) RSAkey, (LPCTSTR)fNameClient, vmyPassword);

}
catch(CException* pe)
{
AfxMessageBox(_T("Error"));
pe->ReportError();
}

keyFile.Close();
return ;
}

Thank you,
Mariana


Complete thread: