mirror of
https://github.com/upa/mscp.git
synced 2026-03-05 23:17:31 +08:00
add auth callback for input passphrase of privkey
This commit is contained in:
14
src/ssh.c
14
src/ssh.c
@@ -95,10 +95,24 @@ static int ssh_authenticate(ssh_session ssh, struct ssh_opts *opts)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _ssh_getpass(const char *prompt, char *buf, size_t len, int echo,
|
||||||
|
int verify, void *userdata)
|
||||||
|
{
|
||||||
|
return ssh_getpass(prompt, buf, len, echo, verify);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ssh_callbacks_struct cb = {
|
||||||
|
.auth_function = _ssh_getpass,
|
||||||
|
.userdata = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
static ssh_session ssh_init_session(char *sshdst, struct ssh_opts *opts)
|
static ssh_session ssh_init_session(char *sshdst, struct ssh_opts *opts)
|
||||||
{
|
{
|
||||||
ssh_session ssh = ssh_new();
|
ssh_session ssh = ssh_new();
|
||||||
|
|
||||||
|
ssh_callbacks_init(&cb);
|
||||||
|
ssh_set_callbacks(ssh, &cb);
|
||||||
|
|
||||||
if (ssh_set_opts(ssh, opts) != 0)
|
if (ssh_set_opts(ssh, opts) != 0)
|
||||||
goto free_out;
|
goto free_out;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user