server - libssh Error: Timeout connecting qt/c++ -


i have used libssh library, using following code, want communicate server.

void mainwindow::test() {  ssh_session session; ssh_channel channel; int rc, port = 3389; char buffer[1024]; unsigned int nbytes;  printf("session...\n"); session = ssh_new(); if (session == null) exit(-1); ssh_options_set(session, ssh_options_host, "37.143.120.200"); ssh_options_set(session, ssh_options_port, &port); ssh_options_set(session, ssh_options_user, "xxx");  printf("connecting...\n"); rc = ssh_connect(session); if (rc != ssh_ok) error(session);  printf("password autentication...\n"); rc = ssh_userauth_password(session,"xxx","xxx"); if (rc != ssh_auth_success) error(session);  printf("channel...\n"); channel = ssh_channel_new(session); if (channel == null) exit(-1);  printf("opening...\n"); rc = ssh_channel_open_session(channel); if (rc != ssh_ok) error(session);  printf("executing remote command...\n"); rc = ssh_channel_request_exec(channel, "ls -l"); if (rc != ssh_ok) error(session);  printf("received:\n"); nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); while (nbytes > 0) {     fwrite(buffer, 1, nbytes, stdout);     nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); }   free_channel(channel);  free_session(session);  }  void mainwindow::free_channel(ssh_channel channel)  {    ssh_channel_send_eof(channel);    ssh_channel_close(channel);    ssh_channel_free(channel); }  void mainwindow::free_session(ssh_session session)  {    ssh_disconnect(session);    ssh_free(session); }  void mainwindow::error(ssh_session session)  {    fprintf(stderr, "error: %s\n", ssh_get_error(session));    free_session(session);    exit(-1); } 

but got following error

error: timeout connecting 37.143.120.200 

i tested lot of servers still error above... while target servers clear , working suchas

i use 32-bit windows 10 operating system , qtframework 5.8 :xx


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -