我正在使用C ++开发嵌入式系统。 我实际上尝试将ssh上的系统连接到我的计算机主机上。 我使用这段代码:
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_easy_setopt(curl, CURLOPT_URL,
"sftp://10.0.0.100/");
/* Define our callback to get called when there's data to be written */
curl_easy_setopt(curl, CURLOPT_USERPWD, "root:password");
curl_easy_setopt(curl,CURLOPT_KEYPASSWD,"password");
curl_easy_setopt(curl, CURLOPT_PORT, 22);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1000);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
/* Set a pointer to our struct to pass to the callback */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE,std::string(PublicKey).c_str());
curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE,std::string(PrivateKey).c_str());
curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES,CURLSSH_AUTH_PUBLICKEY);
/* Switch on full protocol/debug output */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
但我的计划结果是:
不幸的是,我无法在我的系统上创建一些ssh
密钥,因为它不接受system()
commandes,所以我直接从另一个系统导入密钥。
将其归因于我的错误原因?