title: curl error - 79 Error in the ssh layer
body: <p>I am using curl library within c++ code. I would like to upload a file to the server using sftp and user authentization. While I manage to do this from windows command line using </p>
  
  <pre><code>curl -k -T f:/temp/openvpn-config.zip -u user:password sftp://fabrika/tmp/
  </code></pre>
  
  <p>calling curl with options</p>
  
  <pre><code>struct stat file_info;
  FILE *fd = fopen(f:/temp/openvpn-config.zip,"rb");
  int res_st = fstat(fileno(fd), &amp;file_info);
  fclose(fd);
  
  ffile.open(f:/temp/openvpn-config.zip,ios::in | ios::binary);
  
  curl_easy_setopt(h_curl, CURLOPT_URL, "sftp://fabrika/tmp/");
  curl_easy_setopt(h_curl, CURLOPT_UPLOAD, 1L);
  curl_easy_setopt(h_curl, CURLOPT_READDATA, (void*)&amp;ffile);
  curl_easy_setopt(h_curl, CURLOPT_READFUNCTION, &amp;ReadCallback);
  curl_easy_setopt(h_curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
  curl_easy_setopt(h_curl, CURLOPT_SSL_VERIFYPEER, 0L);
  curl_easy_setopt(h_curl, CURLOPT_USERPWD, "user:password");
  </code></pre>
  
  <p>gives me error code 79, which tranlates into "Error in the ssh layer". I checked the fstat result, the file size passed to curl is correct.</p>
  
  <p>Edit: Forgot to add debug information from verbose mode, here it is</p>
  
  <pre><code>Hostname was NOT found in DNS cache
  Adding handle: conn: 0x4236ef0
  Adding handle: send: 0
  Adding handle: recv: 0
  Curl_addHandleToPipeline: length: 1
  - Conn 0 (0x4236ef0) send_pipe: 1, recv_pipe: 0
  Trying 192.168.3.1...
  Connected to fabrika (192.168.3.1) port 22 (#0)
  SSH MD5 fingerprint: 9e73dade666cbbac9a82adfeffbd9f18
  SSH authentication methods available: publickey,password
  Using ssh public key file id_dsa.pub
  Using ssh private key file id_dsa
  SSH public key authentication failed: Unable to open public key file
  Initialized password authentication
  Authentication complete
  Upload failed: Operation failed (4/-31)
  Connection #0 to host fabrika left intact
  </code></pre>
  
  <p>Clearly I am missing some parameter used by the command line curl which does the trick, I'll be grateful for any suggestions.</p>
  
  <p>Petr</p>