您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ssh_userauth_none函数代码示例

51自学网 2021-06-03 08:19:00
  C++
这篇教程C++ ssh_userauth_none函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ssh_userauth_none函数的典型用法代码示例。如果您正苦于以下问题:C++ ssh_userauth_none函数的具体用法?C++ ssh_userauth_none怎么用?C++ ssh_userauth_none使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ssh_userauth_none函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: torture_algorithms_zlib

static void torture_algorithms_zlib(void **state) {    ssh_session session = *state;    int rc;    rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");    assert_true(rc == SSH_OK);    rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib");    assert_true(rc == SSH_OK);    rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib");    assert_true(rc == SSH_OK);    rc = ssh_connect(session);    if (ssh_get_openssh_version(session)) {        assert_false(rc == SSH_OK);    } else {        assert_true(rc == SSH_OK);        rc = ssh_userauth_none(session, NULL);        if (rc != SSH_OK) {            rc = ssh_get_error_code(session);            assert_true(rc == SSH_REQUEST_DENIED);        }    }    ssh_disconnect(session);}
开发者ID:FuckingCoder,项目名称:libssh,代码行数:28,


示例2: torture_auth_agent_nonblocking

static void torture_auth_agent_nonblocking(void **state) {    struct torture_state *s = *state;    ssh_session session = s->ssh.session;    int rc;    if (!ssh_agent_is_running(session)){        print_message("*** Agent not running. Test ignored/n");        return;    }    rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_ALICE);    assert_int_equal(rc, SSH_OK);    rc = ssh_connect(session);    assert_int_equal(rc, SSH_OK);    rc = ssh_userauth_none(session,NULL);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY);    ssh_set_blocking(session,0);    do {      rc = ssh_userauth_agent(session, NULL);    } while (rc == SSH_AUTH_AGAIN);    assert_int_equal(rc, SSH_AUTH_SUCCESS);}
开发者ID:Paxxi,项目名称:libssh,代码行数:30,


示例3: ssh_options_set_host

SSH_SESSION *connect_host(const char *hostname){  SSH_SESSION *session;  SSH_OPTIONS *options;  int auth=0;  int state;  options=ssh_options_new();  ssh_options_set_host(options,hostname);  session=ssh_new();  ssh_set_options(session,options);  if(ssh_connect(session)){    fprintf(stderr,"Connection failed : %s/n",ssh_get_error(session));    ssh_disconnect(session);    return NULL;  }  state = ssh_session_is_known_server(session);  switch(state){    case SSH_SERVER_KNOWN_OK:      break; /* ok */    case SSH_SERVER_KNOWN_CHANGED:      fprintf(stderr,"Host key for server changed : server's one is now :/n");      fprintf(stderr,"For security reason, connection will be stopped/n");      ssh_disconnect(session);      ssh_finalize();      return NULL;    case SSH_SERVER_FOUND_OTHER:      fprintf(stderr,"The host key for this server was not found but an other type of key exists./n");      fprintf(stderr,"An attacker might change the default server key to confuse your client"          "into thinking the key does not exist/n"          "We advise you to rerun the client with -d or -r for more safety./n");      ssh_disconnect(session);      ssh_finalize();      return NULL;    case SSH_SERVER_NOT_KNOWN:      fprintf(stderr,"The server is unknown. Leaving now");      ssh_disconnect(session);      return NULL;    case SSH_SERVER_ERROR:      fprintf(stderr,"%s",ssh_get_error(session));      ssh_disconnect(session);      return NULL;  }  ssh_userauth_none(session, NULL);  auth=ssh_userauth_autopubkey(session, NULL);  if(auth==SSH_AUTH_ERROR){    fprintf(stderr,"Authenticating with pubkey: %s/n",ssh_get_error(session));    ssh_disconnect(session);    return NULL;  }  if(auth!=SSH_AUTH_SUCCESS){    fprintf(stderr,"Authentication failed: %s/n",ssh_get_error(session));    ssh_disconnect(session);    return NULL;  }  ssh_log(session, SSH_LOG_FUNCTIONS, "Authentication success");  return session;}
开发者ID:Paxxi,项目名称:libssh,代码行数:60,


示例4: test_algorithm

static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {    int rc;    rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, algo);    assert_int_equal(rc, SSH_OK);    rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, algo);    assert_int_equal(rc, SSH_OK);    rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, hmac);    assert_int_equal(rc, SSH_OK);    rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, hmac);    assert_int_equal(rc, SSH_OK);    rc = ssh_connect(session);    assert_int_equal(rc, SSH_OK);    rc = ssh_userauth_none(session, NULL);    if (rc != SSH_OK) {        rc = ssh_get_error_code(session);        assert_int_equal(rc, SSH_REQUEST_DENIED);    }    ssh_disconnect(session);}
开发者ID:codinn,项目名称:libssh,代码行数:26,


示例5: torture_auth_autopubkey_nonblocking

static void torture_auth_autopubkey_nonblocking(void **state) {    ssh_session session = *state;    char *user = getenv("TORTURE_USER");    int rc;    if (user == NULL) {        print_message("*** Please set the environment variable TORTURE_USER"                      " to enable this test!!/n");        return;    }    rc = ssh_options_set(session, SSH_OPTIONS_USER, user);    assert_true(rc == SSH_OK);    rc = ssh_connect(session);    assert_true(rc == SSH_OK);    ssh_set_blocking(session,0);    do {      rc = ssh_userauth_none(session, NULL);    } while (rc == SSH_AUTH_AGAIN);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY);    do {        rc = ssh_userauth_publickey_auto(session, NULL, NULL);    } while (rc == SSH_AUTH_AGAIN);    assert_true(rc == SSH_AUTH_SUCCESS);}
开发者ID:chrisdew,项目名称:node-libssh,代码行数:35,


示例6: torture_auth_kbdint

static void torture_auth_kbdint(void **state) {    struct torture_state *s = *state;    ssh_session session = s->ssh.session;    int rc;    rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_BOB);    assert_int_equal(rc, SSH_OK);    rc = ssh_connect(session);    assert_int_equal(rc, SSH_OK);    rc = ssh_userauth_none(session,NULL);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_INTERACTIVE);    rc = ssh_userauth_kbdint(session, NULL, NULL);    assert_int_equal(rc, SSH_AUTH_INFO);    assert_int_equal(ssh_userauth_kbdint_getnprompts(session), 1);    rc = ssh_userauth_kbdint_setanswer(session, 0, TORTURE_SSH_USER_BOB_PASSWORD);    assert_false(rc < 0);    rc = ssh_userauth_kbdint(session, NULL, NULL);    /* Sometimes, SSH server send an empty query at the end of exchange */    if(rc == SSH_AUTH_INFO) {        assert_int_equal(ssh_userauth_kbdint_getnprompts(session), 0);        rc = ssh_userauth_kbdint(session, NULL, NULL);    }    assert_int_equal(rc, SSH_AUTH_SUCCESS);}
开发者ID:Paxxi,项目名称:libssh,代码行数:34,


示例7: torture_auth_password

static void torture_auth_password(void **state) {    ssh_session session = *state;    char *user = getenv("TORTURE_USER");    char *password = getenv("TORTURE_PASSWORD");    int rc;    if (user == NULL) {        print_message("*** Please set the environment variable TORTURE_USER"                      " to enable this test!!/n");        return;    }    if (password == NULL) {        print_message("*** Please set the environment variable "                      "TORTURE_PASSWORD to enable this test!!/n");        return;    }    rc = ssh_options_set(session, SSH_OPTIONS_USER, user);    assert_true(rc == SSH_OK);    rc = ssh_connect(session);    assert_true(rc == SSH_OK);    rc = ssh_userauth_none(session, NULL);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_AUTH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_PASSWORD);    rc = ssh_userauth_password(session, NULL, password);    assert_true(rc == SSH_AUTH_SUCCESS);}
开发者ID:chrisdew,项目名称:node-libssh,代码行数:35,


示例8: torture_auth_agent

static void torture_auth_agent(void **state) {    ssh_session session = *state;    char *user = getenv("TORTURE_USER");    int rc;    if (user == NULL) {        print_message("*** Please set the environment variable TORTURE_USER"                      " to enable this test!!/n");        return;    }    if (!agent_is_running(session)){        print_message("*** Agent not running. Test ignored");        return;    }    rc = ssh_options_set(session, SSH_OPTIONS_USER, user);    assert_true(rc == SSH_OK);    rc = ssh_connect(session);    assert_true(rc == SSH_OK);    rc = ssh_userauth_none(session,NULL);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_PUBLICKEY);    rc = ssh_userauth_agent(session, NULL);    assert_true(rc == SSH_AUTH_SUCCESS);}
开发者ID:chrisdew,项目名称:node-libssh,代码行数:31,


示例9: client

static int client(ssh_session session){  int auth=0;  char *banner;  int state;  if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)    return -1;  ssh_options_parse_config(session, NULL);  if(ssh_connect(session)){      fprintf(stderr,"Connection failed : %s/n",ssh_get_error(session));      return -1;  }  state=verify_knownhost(session);  if (state != 0)  	return -1;  ssh_userauth_none(session, NULL);  banner=ssh_get_issue_banner(session);  if(banner){      printf("%s/n",banner);      free(banner);  }  auth=authenticate_console(session);  if(auth != SSH_AUTH_SUCCESS){  	return -1;  } 	forwarding(session);  return 0;}
开发者ID:R4wizard,项目名称:node-libssh,代码行数:29,


示例10: torture_auth_password_nonblocking

static void torture_auth_password_nonblocking(void **state) {    struct torture_state *s = *state;    ssh_session session = s->ssh.session;    int rc;    rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_BOB);    assert_int_equal(rc, SSH_OK);    rc = ssh_connect(session);    assert_int_equal(rc, SSH_OK);    ssh_set_blocking(session,0);    do {      rc = ssh_userauth_none(session, NULL);    } while (rc == SSH_AUTH_AGAIN);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_AUTH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_PASSWORD);    do {      rc = ssh_userauth_password(session, NULL, TORTURE_SSH_USER_BOB_PASSWORD);    } while(rc==SSH_AUTH_AGAIN);    assert_int_equal(rc, SSH_AUTH_SUCCESS);}
开发者ID:Paxxi,项目名称:libssh,代码行数:30,


示例11: test_several_auth_methods

static int test_several_auth_methods(ssh_session session, url_t* urlp){  int rc = ssh_userauth_none(session, NULL);  /* if (rc != SSH_AUTH_SUCCESS) {      return rc;  } */  int method = ssh_userauth_list(session, NULL);  if (method & SSH_AUTH_METHOD_NONE)  {    rc = authenticate_none(session);    if (rc == SSH_AUTH_SUCCESS) return rc;  }  if (method & SSH_AUTH_METHOD_PUBLICKEY)  {    rc = authenticate_pubkey(session);    if (rc == SSH_AUTH_SUCCESS) return rc;  }  if (method & SSH_AUTH_METHOD_INTERACTIVE)  {    rc = authenticate_kbdint(session);    if (rc == SSH_AUTH_SUCCESS) return rc;  }  if (method & SSH_AUTH_METHOD_PASSWORD)  {    rc = authenticate_password(session, urlp);    if (rc == SSH_AUTH_SUCCESS) return rc;  }  return SSH_AUTH_ERROR;}
开发者ID:casualuser,项目名称:yafc,代码行数:30,


示例12: remmina_ssh_init_session

gbooleanremmina_ssh_init_session (RemminaSSH *ssh){	gint verbosity;	ssh->callback = g_new0 (struct ssh_callbacks_struct, 1);	ssh->callback->userdata = ssh;	/* Init & startup the SSH session */	ssh->session = ssh_new ();	ssh_options_set (ssh->session, SSH_OPTIONS_HOST, ssh->server);	ssh_options_set (ssh->session, SSH_OPTIONS_PORT, &ssh->port);	ssh_options_set (ssh->session, SSH_OPTIONS_USER, ssh->user);	if (remmina_log_running ())	{		verbosity = SSH_LOG_RARE;		ssh_options_set (ssh->session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);		ssh->callback->log_function = remmina_ssh_log_callback;	}	ssh_callbacks_init (ssh->callback);	ssh_set_callbacks(ssh->session, ssh->callback);	if (ssh_connect (ssh->session))	{		remmina_ssh_set_error (ssh, _("Failed to startup SSH session: %s"));		return FALSE;	}	/* Try the "none" authentication */	if (ssh_userauth_none (ssh->session, NULL) == SSH_AUTH_SUCCESS)	{		ssh->authenticated = TRUE;	}	return TRUE;}
开发者ID:B0SB05,项目名称:Remmina,代码行数:35,


示例13: torture_auth_none_nonblocking

static void torture_auth_none_nonblocking(void **state) {    struct torture_state *s = *state;    ssh_session session = s->ssh.session;    int rc;    rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_ALICE);    assert_int_equal(rc, SSH_OK);    rc = ssh_connect(session);    assert_int_equal(rc, SSH_OK);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_int_equal(ssh_get_error_code(session), SSH_REQUEST_DENIED);    }    ssh_set_blocking(session,0);    do {        rc = ssh_userauth_none(session,NULL);    } while (rc == SSH_AUTH_AGAIN);    assert_int_equal(rc, SSH_AUTH_DENIED);    assert_int_equal(ssh_get_error_code(session), SSH_REQUEST_DENIED);}
开发者ID:cedral,项目名称:libssh,代码行数:25,


示例14: torture_auth_kbdint_nonblocking

static void torture_auth_kbdint_nonblocking(void **state) {    ssh_session session = *state;    char *user = getenv("TORTURE_USER");    char *password = getenv("TORTURE_PASSWORD");    int rc;    if (user == NULL) {        print_message("*** Please set the environment variable TORTURE_USER"                      " to enable this test!!/n");        return;    }    if (password == NULL) {        print_message("*** Please set the environment variable "                      "TORTURE_PASSWORD to enable this test!!/n");        return;    }    rc = ssh_options_set(session, SSH_OPTIONS_USER, user);    assert_true(rc == SSH_OK);    rc = ssh_connect(session);    assert_true(rc == SSH_OK);    ssh_set_blocking(session,0);    do {      rc = ssh_userauth_none(session, NULL);    } while (rc == SSH_AUTH_AGAIN);    /* This request should return a SSH_REQUEST_DENIED error */    if (rc == SSH_ERROR) {        assert_true(ssh_get_error_code(session) == SSH_REQUEST_DENIED);    }    rc = ssh_userauth_list(session, NULL);    assert_true(rc & SSH_AUTH_METHOD_INTERACTIVE);    do {        rc = ssh_userauth_kbdint(session, NULL, NULL);    } while (rc == SSH_AUTH_AGAIN);    assert_true(rc == SSH_AUTH_INFO);    assert_int_equal(ssh_userauth_kbdint_getnprompts(session), 1);    do {        rc = ssh_userauth_kbdint_setanswer(session, 0, password);    } while (rc == SSH_AUTH_AGAIN);    assert_false(rc < 0);    do {        rc = ssh_userauth_kbdint(session, NULL, NULL);    } while (rc == SSH_AUTH_AGAIN);    /* Sometimes, SSH server send an empty query at the end of exchange */    if(rc == SSH_AUTH_INFO) {        assert_int_equal(ssh_userauth_kbdint_getnprompts(session), 0);        do {            rc = ssh_userauth_kbdint(session, NULL, NULL);        } while (rc == SSH_AUTH_AGAIN);    }    assert_true(rc == SSH_AUTH_SUCCESS);}
开发者ID:chrisdew,项目名称:node-libssh,代码行数:58,


示例15: authenticate_console

int authenticate_console(ssh_session session, char* pwd){    int rc;    int method;    char password[128] = {0};    char *banner;    // Try to authenticate    rc = ssh_userauth_none(session, NULL);    if (rc == SSH_AUTH_ERROR) {        error(session);        return rc;    }    method = ssh_auth_list(session);    while (rc != SSH_AUTH_SUCCESS) {        // Try to authenticate with public key first        if (method & SSH_AUTH_METHOD_PUBLICKEY) {            rc = ssh_userauth_autopubkey(session, NULL);            if (rc == SSH_AUTH_ERROR) {                error(session);                return rc;            } else if (rc == SSH_AUTH_SUCCESS) {                break;            }        }/*        // Try to authenticate with keyboard interactive";        if (method & SSH_AUTH_METHOD_INTERACTIVE) {            rc = authenticate_kbdint(session, NULL);            if (rc == SSH_AUTH_ERROR) {                error(session);                return rc;            } else if (rc == SSH_AUTH_SUCCESS) {                break;            }        }        if (ssh_getpass("Password: ", password, sizeof(password), 0, 0) < 0) {            return SSH_AUTH_ERROR;        }*/        // Try to authenticate with password          strncpy(password, pwd, 128);          if (method & SSH_AUTH_METHOD_PASSWORD) {            rc = ssh_userauth_password(session, NULL, password);            if (rc == SSH_AUTH_ERROR) {                error(session);                return rc;            } else if (rc == SSH_AUTH_SUCCESS) {                break;            }        }    }    banner = ssh_get_issue_banner(session);    if (banner) {        printf("%s/n",banner);        free(banner);    }    return rc;}
开发者ID:bertonf,项目名称:NSP2,代码行数:57,


示例16: service_ssh_init

//// dirty workaround here: miscptr is the ptr to the logins, and the first one is used// to test if password authentication is enabled!!//int32_t service_ssh_init(char *ip, int32_t sp, unsigned char options, char *miscptr, FILE * fp, int32_t port, char *hostname) {  // called before the childrens are forked off, so this is the function  // which should be filled if initial connections and service setup has to be  // performed once only.  //  // fill if needed.  //   // return codes:  //   0 all OK  //   1 skip target without generating an error  //   2 skip target because of protocol problems  //   3 skip target because its unreachable#ifdef LIBSSH  int32_t rc, method;  ssh_session session = ssh_new();    if (verbose || debug)    printf("[INFO] Testing if password authentication is supported by ssh://%[email
C++ ssh_xfree函数代码示例
C++ ssh_string_len函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。