我开发了用于身份验证的PAM模块,并且希望SSH使用它。我将其放在/etc/pam.d/sshd
堆栈的顶部,但未调用。我肯定知道该模块能正常工作,因为我将其集成到了登录名中。
我必须如何设置/ etc / ssh / sshd_config才能使用它?
编辑:UsePAM已经设置为yes,还尝试了ChallengeResponseAuthentication
和PasswordAuthentication
yes
和no
值的所有可能组合。
答案 0 :(得分:0)
那是我的错误:该模块实际上是被调用的,但是它试图从控制台读取一行。虽然此功能可以登录,但不能使用SSH。 正确的方法是使用
const char *username = NULL;
const char *password = NULL;
pam_get_item(pamh, PAM_USER, (const void **)&username);
pam_get_item(pamh, PAM_AUTHTOK, (const void **)&password);
这将为username
和password
设置由SSH检索的值。
为了获取密码,请在PasswordAuthentication
中将yes
设置为/etc/ssh/sshd_config
,然后在etc/pam.d/sshd
中将@include common-auth
替换为auth required your-module