Nov 20

[原]解决set_loginuid failed opening loginuid报错 晴

linuxing , 11:36 , 基础知识 » 故障处理 , 评论(1) , 引用(0) , 阅读(33846) , Via 本站原创 | |
   自从使用php-syslog-ng监控日志信息后,经常发现一些过去会忽略的报错信息,目前正逐一解决中。其中一个报错发生在,我使用密钥通过ssh登陆到服务器的时候,日志信息显示:
引用
Nov 19 10:32:20 printserver auth 10:32:20 pam_loginuid[9691]: set_loginuid failed opening loginuid
Nov 19 10:32:20 printserver auth 10:32:20 remote(pam_unix)[9691]: session opened for user root by (uid=0)
Nov 19 10:32:20 printserver auth 10:32:20 sshd[9689]: Accepted publickey for root from 192.168.228.244 port
1487 ssh2

一、原因
操作系统:红旗DC Server 5.0
分析以前的系统日志,并没有发现类似的报错信息,故怀疑是最近的操作导致的。
从两方面分析:
引用
1、openssh-server从4.0p1升级到4.7p1;
2、使用密钥登陆代替原来的密码登陆方式。

先尝试用原来的密码方式登陆,没有报错;再对比其他机器上原4.0p1版的状态,使用密钥登陆,也没有报错。由于我升级openssh-server的时候,使用它自带的默认配置文件而非系统4.0p1版的配置,故觉得报错,和配置及使用密钥登陆都有关。

二、解决
经查找资料后测试,可通过修改openssh-server的配置文件解决问题。
修改/etc/ssh/sshd_config为:
引用
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no  #关闭挑战应答方式
UsePAM no  #不使用PAM认证

保存后,重启sshd服务即可。

三、说明
上述两个参数的说明,可从帮助文档得到注解:
引用
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.

简单来讲,就是如果打开UsePAM,则会根据ChallengeResponseAuthentication来决定是否使用挑战应答方式(我不知道是否这样翻译)。而该方式是根据密码判断的,不能和密钥登陆兼容,所以会出现报错。
不同的配置,可从日志中得到完全不同的结果:
1、关闭ChallengeResponseAuthentication和打开UsePAM
使用密钥登陆:
引用
Nov 19 10:57:20 printserver auth 10:57:20 sshd(pam_unix)[10322]: session opened for user root by root(uid=0)
Nov 19 10:57:20 printserver auth 10:57:20 sshd[10320]: Accepted publickey for root from 192.168.228.244 port 1595 ssh2

2、打开ChallengeResponseAuthentication和UsePAM
使用密钥登陆就会报错,而使用密码登陆是正常的:
引用
Nov 19 12:23:33 printserver sshd(pam_unix)[24454]: session opened for user root by root(uid=0)


四、其他
在Google的时候,发现有另外一种解决方法:点击
就是修改/etc/pam.d/sshd,把下面这行注释:
引用
session required pam_loginuid.so

不过,我在系统中并没有找到这行。反而,从日志可以看到,报错是由PAM调用remote发出的,所以,我修改/etc/pam.d/remote,把这行注释:
引用
session    required     pam_loginuid.so

这样,确认不会再报上面的错误。但登陆的时候,日志就会显示:
引用
Nov 19 10:06:31 printserver sshd[9582]: Accepted publickey for root from 192.168.228.244
port 1228 ssh2
Nov 19 10:06:31 printserver remote(pam_unix)[9584]: session opened for user root by (uid=0)
Nov 19 10:06:31 login -- root[9584]: ROOT LOGIN ON pts/2 FROM 192.168.228.244

发出信息的主机从printserver改为login了,日志分类会有有错,不利于使用咯。
◎至于因为核心没有打开CONFIG_AUDIT功能引起的解决办法
如:点击
经确认,红旗DC Server 5.0的核心是已经打开CONFIG_AUDIT的,所以,解决方法无效。
Tags: ,
陈友天下 Homepage
2010/05/27 11:06
很好 /etc/pam.d/sshd 我把session    required     pam_loginuid.so注释掉,再service sshd restart 就不再有pam_loginuid错误日志了
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]