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

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

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

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

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

示例1: cockpit_ssh_transport_init

static voidcockpit_ssh_transport_init (CockpitSshTransport *self){  static struct ssh_channel_callbacks_struct channel_cbs = {    .channel_data_function = on_channel_data,    .channel_eof_function = on_channel_eof,    .channel_close_function = on_channel_close,    .channel_signal_function = on_channel_signal,    .channel_exit_signal_function = on_channel_exit_signal,    .channel_exit_status_function = on_channel_exit_status,  };  self->data = g_new0 (CockpitSshData, 1);  self->data->context = g_main_context_get_thread_default ();  if (self->data->context)    g_main_context_ref (self->data->context);  self->data->session = ssh_new ();  g_return_if_fail (self->data->session != NULL);  self->buffer = g_byte_array_new ();  self->queue = g_queue_new ();  memcpy (&self->channel_cbs, &channel_cbs, sizeof (channel_cbs));  self->channel_cbs.userdata = self;  ssh_callbacks_init (&self->channel_cbs);  self->event = ssh_event_new ();}
开发者ID:leospol,项目名称:cockpit,代码行数:30,


示例2: main

int 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,


示例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: session_setup

static 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,


示例5: main

int main(int argc, char **argv){    ssh_session session;    session = ssh_new();    if(ssh_options_getopt(session, &argc, argv)) {      fprintf(stderr, "error parsing command line :%s/n",          ssh_get_error(session));      usage();    }    opts(argc,argv);#ifdef WITH_PCAP    set_pcap(session);#endif    client(session);    ssh_disconnect(session);    ssh_free(session);#ifdef WITH_PCAP    cleanup_pcap();#endif    ssh_finalize();    return 0;}
开发者ID:R4wizard,项目名称:node-libssh,代码行数:26,


示例6: ssh_new

voidSession::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,


示例7: ssh_new

    int SSH::openChannel()    {        int rc;        _logger->trace("Opening SSH channel");        if (_ssh == NULL)        {            _ssh = ssh_new();        }        _channel = ssh_channel_new(_ssh);        if (_channel == NULL)        {            _logger->error("Failed to open SSH channel");            throw SSHException("Failed to open SSH channel", SSHErrorCode::E_CHAN_OPEN_FAILED);        }        rc = ssh_channel_open_session(_channel);        if (rc != SSH_OK)        {            ssh_channel_close(_channel);            ssh_channel_free(_channel);            throw SSHException("Failed to open SSH session", SSHErrorCode::E_SESS_OPEN_FAILED);        }        _bChanOpen = true;        return SSHErrorCode::E_NOERR;    }
开发者ID:subutai-io,项目名称:launcher,代码行数:26,


示例8: 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,


示例9: ssh_login

int 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,


示例10: session_setup

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);    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,


示例11: main

int main(int argc, char **argv){    ssh_session_t *session = NULL;    session = ssh_new();    ssh_callbacks_init(&cb);    ssh_set_callbacks(session,&cb);    if(ssh_options_getopt(session, &argc, argv))    {        fprintf(stderr, "error parsing command line :%s/n",                ssh_get_error(session));        usage();    }    opts(argc,argv);    signal(SIGTERM, do_exit);    client(session);    ssh_disconnect(session);    ssh_free(session);    ssh_finalize();    return 0;}
开发者ID:caidongyun,项目名称:ssh-proxy,代码行数:27,


示例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: process_ssh_target

int process_ssh_target(char * pcAddress, char * pcLogin, char * pcPasswd,char * pcDatafile){ssh_session session;	if ( ( NULL == pcAddress) || ( NULL == pcLogin) || ( NULL == pcPasswd) || ( NULL == pcDatafile)  )	{		printf("ERROR: Incorrect data; somewhere empty string./n");//TODO		return -8;//TODO	}	session = ssh_new();	ssh_callbacks_init(&cb);	ssh_set_callbacks(session,&cb);	user_host_file(pcLogin, pcAddress, pcDatafile);	signal(SIGTERM, do_exit);	/* Create input pipe between two endpoints */	pipe(input_pipe);#if defined(OUT_PIPE)	/* Create output pipe between two endpoints */	pipe(output_pipe);#endif /* OUT_PIPE */	/* Launch Successor to push commands into tray */	iInput_Start("none", 25);#if defined(OUT_PIPE)//	iOutput_Start("", 25);#endif /* OUT_PIPE */	client_ssh(session, pcPasswd);	ssh_disconnect(session);	ssh_free(session);	ssh_finalize();	/* allocated in  <assign_host_file> */	free (user);	/* allocated in  <assign_host_file> */	free (host);	/* Free memory occupied by dynamically stored raw data */	DeleteCmds(&pCmdChain);	return 0;}
开发者ID:metallistov20,项目名称:convinject-1,代码行数:59,


示例14: setup

static void setup(void **state) {    int verbosity=torture_libssh_verbosity();    ssh_session session = ssh_new();    ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);    *state = session;}
开发者ID:dirk,项目名称:node-libssh,代码行数:8,


示例15: new_ssh_session

int new_ssh_session() {  my_ssh_session = ssh_new();  if (my_ssh_session == NULL) {    fprintf(stderr, "Error creating ssh session/n");    return SSH_ERROR;  }  return SSH_OK;}
开发者ID:Makohoek,项目名称:tmux-set-buffer-remote,代码行数:8,


示例16: torture_knownhosts_unknown

static 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,


示例17: libssh_ml_ssh_init

CAMLprim value libssh_ml_ssh_init(void){  ssh_session sess = ssh_new();  if (!sess) {    caml_failwith("Couldn't allocate ssh session");  }  return (value)sess;}
开发者ID:luigy,项目名称:ocaml-libssh,代码行数:9,


示例18: spatch

int spatch(){    ssh_session session = NULL;    ssh_bind sshbind = NULL;    sthreadList* list = NULL;    int port = SERVER_PORT;    sshbind=ssh_bind_new();    //session=ssh_new();    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &port);    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY,                                            KEYS_FOLDER "ssh_host_dsa_key");    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY,                                            KEYS_FOLDER "ssh_host_rsa_key");    if (ssh_bind_listen(sshbind)<0)    {        printf("Error listening to socket: %s/n", ssh_get_error(sshbind));        return 1;    }    printf("Server start on port %d/n", port);    while(1)    {        session=ssh_new();        if (ssh_bind_accept(sshbind, session) == SSH_ERROR)        {            printf("Error accepting a connection: %s/n", ssh_get_error(sshbind));            ssh_free(session);        }        else        {            list = newNodeList(list, session);            if (pthread_create(&(list->thread), NULL, (void*)NewSessionLoop, (void*)&(list->sesData)) != 0)            {                sthreadList* tmp;                ssh_disconnect(session);                ssh_free(session);                tmp = list;                list = list->next;                free(tmp);            }        }    }    if (session)        ssh_free(session);    cleanList(list);    ssh_bind_free(sshbind);    ssh_finalize();    return 0;}
开发者ID:bertonf,项目名称:NSP2,代码行数:56,


示例19: 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_options_set函数代码示例
C++ ssh_log函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。