libssh - 无法连接到localhost

时间:2015-08-12 02:07:36

标签: c ssh libssh

我不知道为什么我的libssh程序无法连接到localhost但它适用于远程主机。

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)

1 个答案:

答案 0 :(得分:1)

您会看到配置/etc/ssh/sshd_config

变化 passwordauthentication nopasswordauthentication yes

参考:Permission denied (publickey,keyboard-interactive)