Subject: RE: Reflection for Secure IT Server

RE: Reflection for Secure IT Server

From: Xu, Qiang (FXSGSC) <Qiang.Xu_at_fujixerox.com>
Date: Mon, 3 May 2010 16:53:33 +0800

Still some problems with Reflection servers.

libssh2 itself seems innocent:
=============================================
qxu_at_durian(pts/3):~/opensrc/libssh2-1.2.4/example[236]$ ./sftp_write 13.xxx.xxx.xxx <user> <pass> test.pdf /Home/Scans/test.pdf
Fingerprint: 7B 98 19 12 F3 A2 14 93 3F 72 85 3C 43 DA 19 EF 7F 9A 3A 6B
libssh2_sftp_init()!
libssh2_sftp_open()!
libssh2_sftp_open() is done, now send data!
all done
=============================================
The file in the remote server is identical to the local one.

However, libcurl doesn't work with the server:
=============================================
/* sample source code */
#include <stdio.h>
#include <sys/stat.h>
#include <curl/curl.h>

int main(int argc, char *argv[])
{
  CURLcode ret;
  CURL *hnd = curl_easy_init();
  char *localName = "./testSmall.pdf";
  FILE *localFile = NULL;
  struct stat localFileInfo = {0};

  curl_easy_setopt(hnd, CURLOPT_URL, "sftp://13.121.8.133/Home/Scans/testSmall.pdf");
  curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:pass");
  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1);
  curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1);

  if ((localFile = fopen(localName, "r")) != NULL &&
      stat(localName, &localFileInfo) == 0)
  {
      curl_easy_setopt(hnd, CURLOPT_READDATA, localFile);
      curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)localFileInfo.st_size);
      printf("local file size is [%d] bytes\n", (long)localFileInfo.st_size);
  }
  else
  {
      printf("either cannot open local file [%s] or cannot get its size", localName);
      return 1;
  }

  ret = curl_easy_perform(hnd);

  curl_easy_cleanup(hnd);
  return (int)ret;
}

/* result */
xu_at_durian(pts/1):~/opensrc/curl-7.19.6/example[151]$ ./sftp_reflection
local file size is [523340] bytes
* About to connect() to 13.121.8.133 port 22 (#0)
* Trying 13.121.8.133... * connected
* Connected to 13.121.8.133 (13.121.8.133) port 22 (#0)
* SSH authentication methods available: password
* Initialized password authentication
* Authentication complete
=============================================
You can see it hangs there and never finishes after authentication is passed. The file size transferred to the remote server is only 16KB, while the local one is 523,340 bytes. Even VERBOSE flag is set, I still can't get more output info.

I wanted to use the command-line to do a double check, but it got worse:
=============================================
qxu@durian(pts/1):~/opensrc/curl-7.19.6/src[154]$ ./curl -v -u <user>:<pass> -T testSmall.pdf sftp://13.121.8.133/Home/Scans/testSmall.pdf
* About to connect() to 13.121.8.133 port 22 (#0)
* Trying 13.121.8.133... connected
* Connected to 13.121.8.133 (13.121.8.133) port 22 (#0)
* Failed to read known hosts from /home/qxu/.ssh/known_hosts
* SSH host check: 2, key: <none>
* Closing connection #0
* SSL peer certificate or SSH remote key was not OK

curl: (51) SSL peer certificate or SSH remote key was not OK
=============================================
It just does not go on to do password authentication after failing to read the file "known_hosts".

Any help?

Thanks,
Xu Qiang
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-05-03