NSS + Pam + Tacacs +第一个会话失败

时间:2018-12-17 17:31:32

标签: pam nss


我有要授权使用TACACS +服务器的设备。
我有TACACS版本:tac_plus版本F4.0.4.26
我有带有下一个配置的tacacs服务器

accounting file = /var/log/tac_plus.acct
key = testing123
default authentication = file /etc/passwd

user = sf {
default service = permit
login = cleartext 1234
}

user = DEFAULT {
#       login = PAM
        service = ppp protocol = ip {}
}

在设备上,我的NSS具有配置:

/etc/nsswitch.conf

passwd:     files  rf
group:      files
shadow:     files
hosts:      files   dns
networks:   files   dns
protocols:  files
services:   files
ethers:     files
rpc:        files

和其中带有sshd文件的pam.d

# SERVER 1
auth    required                                                                        /lib/security/pam_rf.so
auth    [success=done auth_err=die default=ignore]      /lib/security/pam_tacplus.so            server=172.18.177.162:49 secret=testing123 timeout=5
account sufficient                                      /lib/security/pam_tacplus.so            server=172.18.177.162:49 service=ppp protocol=ip timeout=5
session required                                    /lib/security/pam_rf.so
session sufficient                                      /lib/security/pam_tacplus.so            server=172.18.177.162:49 service=ppp protocol=ip timeout=5
password required                                                                       /lib/security/pam_rf.so

# PAM configuration for the Secure Shell service

# Standard Un*x authentication.
auth include common-auth

# Disallow non-root logins when /etc/nologin exists.
account    required     pam_nologin.so

# Standard Un*x authorization.
account include common-account

# Set the loginuid process attribute.
session    required     pam_loginuid.so

# Standard Un*x session setup and teardown.
session include common-session

# Standard Un*x password updating.
password   include common-password

和问题,当我第一次连接到设备vie TeraTerm时,我看到输入的用户名已添加到/ etc / passwd和/ etc / shadow的会话开始中 但是登录失败,并且在tacacs服务器中我在日志中看到

Mon Dec 17 19:00:05 2018 [25418]: session.peerip is 172.17.236.2
Mon Dec 17 19:00:05 2018 [25418]: forked 5385
Mon Dec 17 19:00:05 2018 [5385]: connect from 172.17.236.2 [172.17.236.2]
Mon Dec 17 19:00:05 2018 [5385]: Found entry for alex in shadow file
Mon Dec 17 19:00:05 2018 [5385]: verify
IN $6$DUikjB1i$4.cM87/pWRZg2lW3gr3TZorAReVL7JlKGA/2.BRi7AAyHQHz6bBenUxGXsrpzXkVvpwp0CrtNYAGdQDYT2gaZ/
Mon Dec 17 19:00:05 2018 [5385]:
IN encrypts to $6$DUikjB1i$AM/ZEXg6UAoKGrFQOzHC6/BpkK0Rw4JSmgqAc.xJ9S/Q7n8.bT/Ks73SgLdtMUAGbLAiD9wnlYlb84YGujaPS/
Mon Dec 17 19:00:05 2018 [5385]: Password is incorrect
Mon Dec 17 19:00:05 2018 [5385]: Authenticating ACLs for user 'DEFAULT' instead of 'alex'
Mon Dec 17 19:00:05 2018 [5385]: pap-login query for 'alex' ssh from 172.17.236.2 rejected
Mon Dec 17 19:00:05 2018 [5385]: login failure: alex 172.17.236.2 (172.17.236.2) ssh

之后,如果我关闭TeraTerm并再次打开它并尝试进行连接,则连接成功建立,然后,如果我关闭TeraTerm并再次打开,则每秒钟尝试都会出现相同的问题。

可能是什么问题,我已经疯了

1 个答案:

答案 0 :(得分:0)

在深入发现问题之后,我发现这是我的错,我使用g ++而不是gcc编译了名称服务。

由于使用

进行名称服务
#include <pwd.h>

定义了用C编写的nss_service_getpwnam_r等函数的接口,因此我必须:

 extern "C" {
   #include <pwd.h>
}

或使用GCC编译我的程序,希望一旦有人遇到同样的问题,它将对他/她有所帮助。祝你好运