I am trying to securely transfer a file between two windows 10 devices, and I 
get error 67, "CURLE_LOGIN_DENIED" when calling curl_easy_perform().  All of 
the curl_easy_setopt() calls return success.

The server has been configured as an SSH server using OpenSSH for Windows 10 
and using OpenSSH commands from a Windows command prompt are successful in 
transferring files. 

The code below is below with changes to the user name, password, IP addresses, 
directories and file names.
I tried the code below commenting out the user password, since we are trying to 
use keys for authentication. 

1. The Server has been configured to use the D: drive.  Is it enough that I 
have  /~/  after the user@IPaddress?  mailto:user@IPaddress
2. What kind of debugging would aid in resolving this issue?

void sftp_send()
{
CURL     *pCurlSessionHandle = NULL;
CURLcode  eResult         = CURLE_OK;
struct    curl_slist *psConnect_to = NULL;
FILE     *pFileReadHandle    = NULL;

pFileReadHandle = fopen( "C:\\Users\\my.name\\.ssh\\client_file_name", "r" );
if ( pFileReadHandle == NULL ) { return -1; }

pCurlSessionHandle = curl_easy_init(); 

if ( pCurlSessionHandle != NULL )
{
CString s = NULL; // For DEBUG ONLY!!
psConnect_to = curl_slist_append( NULL, "189.123.1.2:22:189.76.11.54:22" );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_RESOLVE, psConnect_to );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_URL,
"sftp://[email protected]/~/Users/remote.user_name/dest_file_name"; );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_PROTOCOLS, 
CURLPROTO_SFTP );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_SSH_AUTH_TYPES, 
CURLSSH_AUTH_PUBLICKEY );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_SSH_PUBLIC_KEYFILE,
"/Users/my.name/.ssh/renamed_key.pub" );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_USERNAME, 
"remote.user_name" );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_USERPWD, 
"Secr3tP4s$word!" );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_READFUNCTION, NULL );
eResult = curl_easy_setopt( pCurlSessionHandle, CURLOPT_READDATA, (void 
*)pFileReadHandle );
eResult = curl_easy_perform( pCurlSessionHandle );
if ( eResult != CURLE_OK )
{
s.Format("Failed to perform SFTP key file transfer! err=%d", eResult );
AfxMessageBox(s);
}
curl_easy_cleanup( pCurlSessionHandle );
}

curl_slist_free_all( psConnect_to );
if ( pFileReadHandle != NULL ) { fclose( pFileReadHandle );  }
}

Best Regards,

Mike Loutris
(Email)  [email protected] mailto:[email protected]

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to