这篇教程C++ ssh_options_set函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ssh_options_set函数的典型用法代码示例。如果您正苦于以下问题:C++ ssh_options_set函数的具体用法?C++ ssh_options_set怎么用?C++ ssh_options_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ssh_options_set函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: sshd_setup/* Should work until Apnic decides to assign it :) */#define BLACKHOLE "1.1.1.1"static int sshd_setup(void **state){ torture_setup_sshd_server(state); return 0;}static int sshd_teardown(void **state) { torture_teardown_sshd_server(state); return 0;}static int session_setup(void **state){ struct torture_state *s = *state; int verbosity = torture_libssh_verbosity(); struct passwd *pwd; int rc; pwd = getpwnam("bob"); assert_non_null(pwd); rc = setuid(pwd->pw_uid); assert_return_code(rc, errno); s->ssh.session = ssh_new(); assert_non_null(s->ssh.session); ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); return 0;}static int session_teardown(void **state){ struct torture_state *s = *state; ssh_disconnect(s->ssh.session); ssh_free(s->ssh.session); return 0;}static void torture_connect_nonblocking(void **state) { struct torture_state *s = *state; ssh_session session = s->ssh.session; int rc; rc = ssh_options_set(session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); assert_true(rc == SSH_OK); ssh_set_blocking(session,0); do { rc = ssh_connect(session); assert_true(rc != SSH_ERROR); } while(rc == SSH_AGAIN); assert_true(rc == SSH_OK);}#if 0 /* This does not work with socket_wrapper */static void torture_connect_timeout(void **state) { struct torture_state *s = *state; ssh_session session = s->ssh.session; struct timeval before, after; int rc; long timeout = 2; time_t sec; suseconds_t usec; rc = ssh_options_set(session, SSH_OPTIONS_HOST, BLACKHOLE); assert_true(rc == SSH_OK); rc = ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &timeout); assert_true(rc == SSH_OK); rc = gettimeofday(&before, NULL); assert_true(rc == 0); rc = ssh_connect(session); assert_true(rc == SSH_ERROR); rc = gettimeofday(&after, NULL); assert_true(rc == 0); sec = after.tv_sec - before.tv_sec; usec = after.tv_usec - before.tv_usec; /* Borrow a second for the missing usecs, but don't bother calculating */ if (usec < 0) sec--; assert_in_range(sec, 1, 3);}
开发者ID:kedazo,项目名称:libssh,代码行数:92,
示例2: session_setupstatic int session_setup(void **state){ struct torture_state *s = *state; int verbosity = torture_libssh_verbosity(); struct passwd *pwd; int rc; pwd = getpwnam("bob"); assert_non_null(pwd); rc = setuid(pwd->pw_uid); assert_return_code(rc, errno); s->ssh.session = ssh_new(); assert_non_null(s->ssh.session); rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); assert_ssh_return_code(s->ssh.session, rc); rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); assert_ssh_return_code(s->ssh.session, rc); rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_USER, TORTURE_SSH_USER_ALICE); assert_ssh_return_code(s->ssh.session, rc); return 0;}
开发者ID:cedral,项目名称:libssh,代码行数:29,
示例3: torture_knownhosts_otherstatic void torture_knownhosts_other(void **state){ struct torture_state *s = *state; ssh_session session = s->ssh.session; char known_hosts_file[1024] = {0}; enum ssh_known_hosts_e found; FILE *file = NULL; int rc; snprintf(known_hosts_file, sizeof(known_hosts_file), "%s/%s", s->socket_dir, TORTURE_KNOWN_HOSTS_FILE); rc = ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, known_hosts_file); assert_ssh_return_code(session, rc); rc = ssh_options_set(session, SSH_OPTIONS_HOSTKEYS, "ssh-ed25519"); assert_ssh_return_code(session, rc); file = fopen(known_hosts_file, "w"); assert_non_null(file); fprintf(file, "127.0.0.10 %s/n", torture_get_testkey_pub(SSH_KEYTYPE_RSA)); fclose(file); rc = ssh_connect(session); assert_ssh_return_code(session, rc); found = ssh_session_is_known_server(session); assert_int_equal(found, SSH_KNOWN_HOSTS_OTHER);}
开发者ID:cedral,项目名称:libssh,代码行数:34,
示例4: remmina_ssh_init_sessiongbooleanremmina_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,
示例5: session_setupstatic int session_setup(void **state){ struct torture_state *s = *state; int verbosity = torture_libssh_verbosity(); struct passwd *pwd; bool b = false; int rc; pwd = getpwnam("bob"); assert_non_null(pwd); rc = setuid(pwd->pw_uid); assert_return_code(rc, errno); s->ssh.session = ssh_new(); assert_non_null(s->ssh.session); ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); /* Make sure no other configuration options from system will get used */ rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_PROCESS_CONFIG, &b); assert_ssh_return_code(s->ssh.session, rc); return 0;}
开发者ID:cedral,项目名称:libssh,代码行数:25,
示例6: ssh_loginint ssh_login(const char *user, const char *passwd){ ssh_session ssh_id; int ret = 0; printf("[*] testing => %s:%s:%s/n", target, user, passwd); ssh_id = ssh_new(); ssh_options_set(ssh_id, SSH_OPTIONS_HOST, target); ssh_options_set(ssh_id, SSH_OPTIONS_USER, user); if(ssh_connect(ssh_id) != SSH_OK){ goto end; } if(ssh_userauth_password(ssh_id, NULL, passwd) != SSH_AUTH_SUCCESS){ goto end; } printf("/n/n/tCracked --> [%s : %s]/n/n", user, passwd); ret = 1; end: ssh_disconnect(ssh_id); ssh_free(ssh_id); return ret;}
开发者ID:hc0d3r,项目名称:C,代码行数:28,
示例7: torture_options_set_userstatic void torture_options_set_user(void **state) { ssh_session session = *state; int rc;#ifndef _WIN32# ifndef NSS_BUFLEN_PASSWD# define NSS_BUFLEN_PASSWD 4096# endif /* NSS_BUFLEN_PASSWD */ struct passwd pwd; struct passwd *pwdbuf; char buf[NSS_BUFLEN_PASSWD]; /* get local username */ rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf); assert_true(rc == 0);#endif /* _WIN32 */ rc = ssh_options_set(session, SSH_OPTIONS_USER, "guru"); assert_true(rc == 0); assert_string_equal(session->opts.username, "guru"); rc = ssh_options_set(session, SSH_OPTIONS_USER, NULL); assert_true(rc == 0);#ifndef _WIN32 assert_string_equal(session->opts.username, pwd.pw_name);#endif}
开发者ID:DouglasHeriot,项目名称:libssh,代码行数:28,
示例8: test_algorithmstatic 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,
示例9: mainint main(){ ssh_session my_ssh_session; int rc; int port = 22; my_ssh_session = ssh_new(); if(my_ssh_session == NULL) exit(-1); ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost"); ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port); ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "root"); rc = ssh_connect(my_ssh_session); if(rc != SSH_OK) { fprintf(stderr, "Error connecting to localhost: %s/n", ssh_get_error(my_ssh_session)); exit(-1); } scp_write(my_ssh_session); ssh_disconnect(my_ssh_session); ssh_free(my_ssh_session);}
开发者ID:novice555,项目名称:cpe24-project,代码行数:25,
示例10: torture_algorithms_zlibstatic 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,
示例11: host_ SSH::SSH(const std::string& host, const std::string& user, const std::string& pass, const std::string port): host_(host),user_(user),pass_(pass),sftp_(0) { std::string timeout = getEnv(envTIMEOUT); timeout_ = atol(timeout.c_str()); if (timeout_ == 0) { throw Error(1, "Timeout Environmental Variable must be a positive integer."); } session_ = ssh_new(); if (session_ == NULL) { throw Error(1, "Unable to create the the ssh session"); } // try to connect ssh_options_set(session_, SSH_OPTIONS_HOST, host_.c_str()); ssh_options_set(session_, SSH_OPTIONS_USER, user_.c_str()); ssh_options_set(session_, SSH_OPTIONS_TIMEOUT, &timeout_); if (port != "") ssh_options_set(session_, SSH_OPTIONS_PORT_STR, port.c_str()); if (ssh_connect(session_) != SSH_OK) { throw Error(1, ssh_get_error(session_)); } // Authentication if (ssh_userauth_password(session_, NULL, pass_.c_str()) != SSH_AUTH_SUCCESS) { throw Error(1, ssh_get_error(session_)); } }
开发者ID:obklar,项目名称:exiv2,代码行数:28,
示例12: ssh_newvoidSession::connect() { if (this->c_session != NULL) { this->disconnect(); } this->c_session = ssh_new(); if (this->c_session == NULL) { throw std::runtime_error("Cannot start session"); } ssh_options_set(this->c_session, SSH_OPTIONS_HOST, this->hostname.c_str()); ssh_options_set(this->c_session, SSH_OPTIONS_PORT, &this->port); int rc = ssh_connect(this->c_session); if (rc != SSH_OK) { fprintf(stderr, "Error connecting to localhost: %s/n", ssh_get_error(this->c_session)); throw std::runtime_error("Cannot connect to server"); } if (this->password_auth) { rc = ssh_userauth_password(this->c_session, NULL, this->password.c_str()); if (rc != SSH_AUTH_SUCCESS) { throw std::runtime_error("Cannot authenticate with server"); } } else { rc = ssh_userauth_autopubkey(this->c_session, NULL); if (rc != SSH_AUTH_SUCCESS) { throw std::runtime_error("Cannot authenticate with server"); } }}
开发者ID:niwinz,项目名称:py-libssh,代码行数:33,
示例13: torture_knownhosts_unknownstatic void torture_knownhosts_unknown(void **state){ struct torture_state *s = *state; ssh_session session = s->ssh.session; char known_hosts_file[1024] = {0}; enum ssh_known_hosts_e found; int rc; snprintf(known_hosts_file, sizeof(known_hosts_file), "%s/%s", s->socket_dir, TORTURE_KNOWN_HOSTS_FILE); rc = ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, known_hosts_file); assert_ssh_return_code(session, rc); rc = ssh_options_set(session, SSH_OPTIONS_HOSTKEYS, "ssh-ed25519"); assert_ssh_return_code(session, rc); rc = ssh_connect(session); assert_ssh_return_code(session, rc); found = ssh_session_is_known_server(session); assert_int_equal(found, SSH_KNOWN_HOSTS_UNKNOWN); rc = ssh_session_update_known_hosts(session); assert_ssh_return_code(session, rc); ssh_disconnect(session); ssh_free(session); /* connect again and check host key */ session = ssh_new(); assert_non_null(session); s->ssh.session = session; rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); assert_ssh_return_code(s->ssh.session, rc); rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_USER, TORTURE_SSH_USER_ALICE); assert_ssh_return_code(s->ssh.session, rc); rc = ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, known_hosts_file); assert_ssh_return_code(session, rc); rc = ssh_connect(session); assert_ssh_return_code(session, rc); /* ssh-rsa is the default but libssh should try ssh-ed25519 instead */ found = ssh_session_is_known_server(session); assert_int_equal(found, SSH_KNOWN_HOSTS_OK); /* session will be freed by session_teardown() */}
开发者ID:cedral,项目名称:libssh,代码行数:58,
示例14: launch_connect/** * Initialize the connection of the server * @param QString server the address of the SSH server * @param QString login the login for the SSH server * @param int port the port of the SSH server * @return bool true if it's ok, false else */bool Kssh::launch_connect(QString server, QString login, int port){ #ifdef DEBUG int log = SSH_LOG_FUNCTIONS; #else int log = SSH_LOG_NOLOG; #endif // define the log level if (ssh_options_set(this->m_session, SSH_OPTIONS_LOG_VERBOSITY, &log) < 0) {#ifdef DEBUG Klog::debug("impossible to set SSH_OPTIONS_LOG_VERBOSITY");#endif return false; } // define the login if (ssh_options_set(this->m_session, SSH_OPTIONS_USER, login.toStdString().data()) < 0) {#ifdef DEBUG Klog::debug("impossible to set SSH_OPTIONS_USER");#endif return false; } // define the host if (ssh_options_set(this->m_session, SSH_OPTIONS_HOST, server.toStdString().data()) < 0) {#ifdef DEBUG Klog::debug("impossible to set SSH_OPTIONS_HOST");#endif return false; } // define the port if (ssh_options_set(this->m_session, SSH_OPTIONS_PORT, &port) < 0) {#ifdef DEBUG Klog::debug("impossible to set SSH_OPTIONS_PORT");#endif return false; } // define the knownhosts filename QString known_hosts = Kconfig::getKnownHosts(); if (ssh_options_set(this->m_session, SSH_OPTIONS_KNOWNHOSTS, known_hosts.toStdString().data()) < 0) {#ifdef DEBUG Klog::debug("impossible to set SSH_OPTIONS_KNOWNHOSTS");#endif return false; } // launch the connection if (ssh_connect(this->m_session) == SSH_ERROR) { Klog::error(QString("Connection failed : ") + QString(ssh_get_error(this->m_session))); this->disconnect(); return false; } return true;}
开发者ID:leblanc-simon,项目名称:qlaunchoverssh,代码行数:65,
示例15: setupstatic void setup(void **state) { int verbosity = torture_libssh_verbosity(); ssh_session session = ssh_new(); ssh_options_set(session, SSH_OPTIONS_HOST, "localhost"); ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); *state = session;}
开发者ID:AudriusButkevicius,项目名称:node-libssh,代码行数:9,
示例16: connect_ssh_sessionint connect_ssh_session(const char* user, const char* host) { ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, user); ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, host); int ret = ssh_connect(my_ssh_session); if (ret != SSH_OK) { fprintf(stderr, "Error connecting to %s: %s/n", host, ssh_get_error(my_ssh_session)); } return ret;}
开发者ID:Makohoek,项目名称:tmux-set-buffer-remote,代码行数:10,
示例17: clientstatic int client(ssh_session_t *session){ int auth=0; char *banner; int state; if (user) { if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) { return -1; } } if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0) { return -1; } if (proxycommand != NULL) { if(ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, proxycommand)) { 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; } if(!cmds[0]) { shell(session); } else { batch_shell(session); } return 0;}
开发者ID:caidongyun,项目名称:ssh-proxy,代码行数:54,
示例18: sn_ssh_get_sessionssh_session sn_ssh_get_session(int verbosity) { ssh_session s = ssh_new(); if (!s) { std::cerr << "[ssh/tfail] Error getting SSH session object." << std::endl; exit(ERR_NO_SSH_SESSION); } ssh_options_set(s, SSH_OPTIONS_HOST, "segfault.party"); ssh_options_set(s, SSH_OPTIONS_USER, "bots"); ssh_options_set(s, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); return s;}
开发者ID:svkampen,项目名称:Sonance,代码行数:12,
示例19: session_setupstatic int session_setup(void **state){ struct torture_state *s = *state; int verbosity = torture_libssh_verbosity(); s->ssh.session = ssh_new(); assert_non_null(s->ssh.session); ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER); return 0;}
开发者ID:Paxxi,项目名称:libssh,代码行数:13,
示例20: torture_options_set_hoststatic void torture_options_set_host(void **state) { ssh_session session = *state; int rc; rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost"); assert_true(rc == 0); assert_string_equal(session->opts.host, "localhost"); rc = ssh_options_set(session, SSH_OPTIONS_HOST, "[email C++ ssh_print_hexa函数代码示例 C++ ssh_new函数代码示例
|