|
BOOL CreateSecurityCredentials( |
|
DWORD dwProtocol, |
|
|
DWORD dwOptions, |
|
|
LPCTSTR lpszKeyFile, |
|
|
LPCTSTR lpszPassword |
|
); |
BOOL CreateSecurityCredentials( |
|
LPCTSTR lpszKeyFile, |
|
|
LPCTSTR lpszPassword |
|
); |
BOOL CreateSecurityCredentials( |
|
LPCTSTR lpszKeyFile |
|
); |
The CreateSecurityCredentials method establishes the
security credentials for the client session.
Parameters
- dwProtocol
- A bitmask of supported security protocols.
Value |
Description |
SECURITY_PROTOCOL_SSH2 |
Version 2.0 of the protocol will be used when establishing
the connection. Currently, this is the only supported protocol
option for SSH connections. In older versions of SocketTools,
you had the option of selecting either version 1.0 or 2.0;
however, version 1.0 is no longer considered secure and is not
supported. |
- dwOptions
- This parameter is reserved for future use and should always be a
value of zero.
- lpszKeyFile
- A pointer to a string which specifies the name of a private key
file that used when authenticating the client connection. The
private key file must be in the standard PEM format defined in RFC
1422. Both the standard RSA private key format and the proprietary
OpenSSH format are supported.
- lpszPassword
- A pointer to a string which specifies the
password for the private key file. A value of NULL specifies that
no password is required.
Return Value
If the method succeeds, the return value is non-zero. If the
method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
This method is only required if you wish to authenticate the client
session using a private key file instead of an account password.
The lpszKeyFile path can use environment variables enclosed
in percent symbols, and the path to the private key file will be normalized.
It is recommended you always use an absolute path to the private key file.
If you do not include a path, it will use the current working directory
for the process. This can produce inconsistent results with multithreaded
applications because the current working directory for a process is a
global value and it can be changed by any thread at any time.
Example
CSshClient sshClient;
LPCTSTR lpszKeyFile = _T("%USERPROFILE%\\.ssh\\id_rsa.pem");
if (!sshClient.CreateSecurityCredentials(lpszKeyFile))
{
sshClient.ShowError();
return;
}
bConnected = sshClient.Connect(strHostName,
SSH_PORT_DEFAULT,
strUserName,
NULL,
SSH_TIMEOUT,
SSH_OPTION_KEEPALIVE);
if (!bConnected)
{
sshClient.ShowError();
return;
}
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools11.h
Import Library: cstshv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
Connect,
DeleteSecurityCredentials,
GetSecurityInformation,
SECURITYCREDENTIALS
|
|