MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / connect_ssh

Method connect_ssh

src/FTPClientWrapperSSH.cpp:414–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412//////////////////////////////////////////////////
413
414int FTPClientWrapperSSH::connect_ssh() {
415 ssh_session session;
416 int auth = 0;
417 int verbosity = SSH_LOG_NOLOG;
418
419 if(ssh_init() < 0) {
420 return -1;
421 }
422
423 session=ssh_new();
424 if (session == NULL) {
425 return -1;
426 }
427
428 if (_HostsFile) {
429 if (ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, _HostsFile) < 0) {
430 ssh_free(session);
431 return -1;
432 }
433 }
434
435 if (ssh_options_set(session, SSH_OPTIONS_USER, m_username) < 0) {
436 ssh_free(session);
437 return -1;
438 }
439
440 if (ssh_options_set(session, SSH_OPTIONS_HOST, m_hostname) < 0) {
441 ssh_free(session);
442 return -1;
443 }
444
445 if (ssh_options_set(session, SSH_OPTIONS_PORT, &m_port) < 0) {
446 ssh_free(session);
447 return -1;
448 }
449
450 ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
451 ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &m_timeout);
452
453 if(ssh_connect(session)) {
454 OutErr("[SFTP] Connection failed : %s\n",ssh_get_error(session));
455 ssh_disconnect(session);
456 ssh_free(session);
457 return -1;
458 }
459
460 if(verify_knownhost(session) < 0) {
461 ssh_disconnect(session);
462 ssh_free(session);
463 return -1;
464 }
465
466 auth = authenticate(session);
467 if(auth == -1) {
468 ssh_disconnect(session);
469 ssh_free(session);
470 return -1;
471 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected