MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / authentication

Method authentication

Src/SSH/ChannelSSH.cpp:374–448  ·  view source on GitHub ↗

\see: https://api.libssh.org/stable/libssh_tutor_authentication.html

Source from the content-addressed store, hash-verified

372
373//! \see: https://api.libssh.org/stable/libssh_tutor_authentication.html
374int CChannelSSH::authentication(
375 ssh_session session,
376 const QString szUser,
377 const QString szPassword,
378 const QString szPassphrase,
379 const int nMethod)
380{
381 int nRet = 0;
382 int nServerMethod = nMethod;
383
384 qDebug(log) << "Authentication method:" << nMethod;
385 //* Get authentication list from ssh server
386 nRet = ssh_userauth_none(session,
387 szUser.toStdString().c_str());
388 qDebug(log) << "ssh_userauth_none:" << nRet;
389 if(SSH_AUTH_SUCCESS == nRet)
390 return 0;
391
392 char *banner = nullptr;
393 banner = ssh_get_issue_banner(session);
394 if (banner)
395 {
396 qInfo(log) << "banner:" << banner;
397 free(banner);
398 }
399
400 nServerMethod = ssh_userauth_list(session,
401 szUser.toStdString().c_str());
402 qDebug(log) << "ssh_userauth_list:" << nServerMethod;
403 //*/
404
405 if(nServerMethod & nMethod & SSH_AUTH_METHOD_PUBLICKEY) {
406 auto &user = m_pParameter->m_Net.m_User;
407 if(user.GetUseSystemFile()) {
408 qDebug(log) << "User authentication with ssh_userauth_publickey_auto";
409 nRet = ssh_userauth_publickey_auto(session,
410 szUser.toStdString().c_str(),
411 szPassphrase.toStdString().c_str());
412 if(SSH_AUTH_SUCCESS == nRet)
413 return 0;
414 QString szErr = tr("SSH failed: Failed authenticating with publickey:")
415 + ssh_get_error(m_Session);
416 qCritical(log) << szErr;
417 setErrorString(szErr);
418 } else {
419 qDebug(log) << "User authentication with publickey";
420 nRet = authenticationPublicKey(
421 m_Session,
422 user.GetUser(),
423 user.GetPublicKeyFile(),
424 user.GetPrivateKeyFile(),
425 user.GetPassphrase());
426 if(SSH_AUTH_SUCCESS == nRet)
427 return 0;
428 }
429 }
430
431 if(nServerMethod & nMethod & SSH_AUTH_METHOD_PASSWORD) {

Callers

nothing calls this directly

Calls 5

GetUseSystemFileMethod · 0.80
GetPublicKeyFileMethod · 0.80
GetPrivateKeyFileMethod · 0.80
GetPassphraseMethod · 0.80
GetUserMethod · 0.45

Tested by

no test coverage detected