cURL / Mailing Lists / curl-library / Single Mail

curl-library

question on libcurl sftp support

From: LIU Ri lang <Rilang.Liu_at_alcatel-lucent.com>
Date: Mon, 6 Sep 2010 10:51:00 +0800

Hello,

I get verbose output for my SFTP testing codes as below(codes attached
after the output log),
What is wrong with my testing codes?

* About to connect() to 135.252.234.82 port 22 (#0)
* Trying 135.252.234.82... * connected
* Connected to 135.252.234.82 (135.252.234.82) port 22 (#0)
* SFTP 0x6da78 state change from SSH_STOP to SSH_S_STARTUP
* Failure establishing ssh session
* SFTP 0x6da78 state change from SSH_S_STARTUP to SSH_SESSION_FREE
* SFTP 0x6da78 state change from SSH_SESSION_FREE to SSH_STOP
* SSH DISCONNECT starts now
* SSH DISCONNECT is done
* Closing connection #0
* Failed initialization
SFTP Error: User: oamops - Port: 22 - error code=2

following is piece of testing codes :

void SFTPSession::connect(const FMK_String& host,
                                   const FMK_String& username,
                                   const FMK_String& password,
                                   const unsigned int& portNumber,
                                   const SFTP_Session::portMode pmode)
                                   throw (ApplicativeException)
{
  _user = username;
  _password = password;
  _portNumber = portNumber;
  _pmode = pmode;

  _remoteUrl<<"sftp://";
  _remoteUrl<<host;

  CURL * curl= curl_easy_init();;
  curl_easy_setopt(curl, CURLOPT_URL,_remoteUrl.data());

  curl_easy_setopt(curl, CURLOPT_USERNAME,_user.data());
  curl_easy_setopt(curl, CURLOPT_PASSWORD,_password.data());

  if(_portNumber!=22)
        curl_easy_setopt(curl, CURLOPT_PORT,_portNumber);

  // set SSH authentication to user name and password
  curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);

   /* Switch on full protocol/debug output */
   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

  CURLcode res = curl_easy_perform(curl);
  fprintf(stderr, "SFTP Error: User: %s - Port: %d - error code=%d
\n", _user , _portNumber , res);
}

Thanks in advance
John

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-06