Как использовать метод nc_callback_sshauth_password для передачи паролей на ходу? - PullRequest
0 голосов
/ 25 апреля 2019

Я выполняю RPC через Netconf и каждый раз мне приходится вводить пароль.Я понял, что мне нужно использовать метод обратного вызова nc_callback_sshauth_password, но мне все еще нужно вводить пароль вручную.Обратитесь за помощью в этом вопросе, где я иду не так.

nc_callback_sshauth_password(netconfCommon::setUsPs);  //callback method call

char * netconfCommon::setUsPs(const char *pU, const char*pH)
{
    return (char*)*myPassword*;
}

Метод обратного вызова не устанавливает пароль автоматически, и мне нужно ввести его вручную.

Вот описание этогоМетод:

/**
 * @brief Set a callback function for passing the user password into the libssh's
 * password authentication method when connecting to 'hostname' as 'username'.
 *
 * To make this function available, you have to include libnetconf_ssh.h.
 *
 * If the func parameter is NULL, the callback is set back to the default function.
 *
 * @ingroup session
 * @param[in] func Callback function to use. The callback function should return
 * a password string for the given username and name of the remote host.
 */
void nc_callback_sshauth_password(char* (*func)(const char* username,
        const char* hostname));

Ссылка: https://github.com/CESNET/libnetconf/blob/master/src/callbacks_ssh.h

...