我正在尝试使用 unix 用户/组数据库作为 hudson 的安全领域。 linux 服务器使用 NIS 进行用户管理。我的帐户可以通过 ssh 登录 hudson 服务器。
并且 hudson 服务器由用户 'hudson' 运行,该用户也是组 'shadow' 的成员,因此 hudson 可以读取/etc/shadow.我使用“测试”按钮测试了配置, hudson 告诉我它运行良好。
但是我无法使用我的unix帐号和密码登录hudson服务器。
而且我在hudson的日志中发现了下面的java异常,
Jan 12, 2011 8:23:42 AM hudson.security.AuthenticationProcessingFilter2 onUnsuccessfulAuthentication
INFO: Login attempt failed
org.acegisecurity.BadCredentialsException: pam_authenticate failed : Authentication failure; nested exception is org.jvnet.libpam.PAMException: pam_authenticate failed : Authentication failure
at hudson.security.PAMSecurityRealm$PAMAuthenticationProvider.authenticate(PAMSecurityRealm.java:100)
at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:195)
at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:45)
at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:71)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:252)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)
at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.jvnet.libpam.PAMException: pam_authenticate failed : Authentication failure
at org.jvnet.libpam.PAM.check(PAM.java:105)
at org.jvnet.libpam.PAM.authenticate(PAM.java:123)
at hudson.security.PAMSecurityRealm$PAMAuthenticationProvider.authenticate(PAMSecurityRealm.java:90)
... 18 more
1 月 17 日更新,
主机是RHEL 4.5,我创建了用户和组shadow,然后将hudson添加到组shadow。
-bash-3.00$ cat /etc/redhat-release
Red Hat Enterprise Linux WS release 4 (Nahant Update 5)
-bash-3.00$ ll /etc/shadow
-r--r----- 1 root shadow 1114 Jan 4 11:37 /etc/shadow
-bash-3.00$ cat /etc/group |grep shadow
shadow:x:44:hudson
我还尝试在另一台 RHEL 4.8 主机上设置 hudson。这次我用 root 运行 hudson,
kzhu0@pek-wb-rhws4_32:~$ ps -ef|grep hudson
root 18764 29161 0 Jan14 pts/5 00:00:33 /usr/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
kzhu0 22404 18833 0 10:52 pts/2 00:00:00 grep hudson
kzhu0@pek-wb-rhws4_32:~$ cat /etc/redhat-release
但我仍然没有运气获得 unix 用户/密码组的工作。我在/var/log/messages 和/var/log/secure 中找不到任何 pam 错误消息。看起来 hudson 在实际使用 pam 进行身份验证之前抛出了异常。 红帽企业 Linux WS 版本 4(Nahant 更新 8)
最佳答案
我调试了 hudson 用于PAM安全领域的libpam4j代码后找到了解决方案。
- 在我的例子中,服务名称必须是“sshd”,因为我想使用 NIS 进行身份验证。 RHEL 4.x 使用 pam 0.77,它严格依赖于 hudson 指定的服务名称。但是我的 Ubuntu 10.04 接受任何无意义的服务名称,它使用 pam 1.1.1。
- 运行hudson的用户必须有读取pam服务文件的权限,/etc/pam.d/sshd是我的文件
关于java - Hudson 无法使用 unix 用户/组进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4666305/