libssh - 无法连接到本地主机
libssh - failed to connect to localhost
我不知道为什么我的 libssh 程序无法连接到本地主机,但它对远程主机工作正常。
ssh_session my_ssh_session = ssh_new();
ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "my_user_name");
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
int rc = ssh_connect(my_ssh_session);
if(rc != SSH_OK) {
printf("Error connecting to the localhost\n");
exit(-1);
}
// Authorized by the password.
rc = ssh_userauth_password(my_ssh_session, "my_user_name", "my_password");
该程序可以成功创建会话,但当我尝试进行身份验证时,它总是在最后一行失败。我从 ssh_userauth_password
得到的错误信息是 (Access denied. Authentication that can continue: publickey,keyboard-interactive)
。
你看配置/etc/ssh/sshd_config
改变
passwordauthentication no
到
passwordauthentication yes
参考:Permission denied (publickey,keyboard-interactive)
我不知道为什么我的 libssh 程序无法连接到本地主机,但它对远程主机工作正常。
ssh_session my_ssh_session = ssh_new();
ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "my_user_name");
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
int rc = ssh_connect(my_ssh_session);
if(rc != SSH_OK) {
printf("Error connecting to the localhost\n");
exit(-1);
}
// Authorized by the password.
rc = ssh_userauth_password(my_ssh_session, "my_user_name", "my_password");
该程序可以成功创建会话,但当我尝试进行身份验证时,它总是在最后一行失败。我从 ssh_userauth_password
得到的错误信息是 (Access denied. Authentication that can continue: publickey,keyboard-interactive)
。
你看配置/etc/ssh/sshd_config
改变
passwordauthentication no
到
passwordauthentication yes
参考:Permission denied (publickey,keyboard-interactive)