Total Pageviews

Saturday 13 October 2012

lastlog_openseek: Couldn’t stat /var/log/lastlog的解决方法


SSH登陆服务器,密码验证能通过,但是无法登陆。报出如下错误。

    lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory

尝试数次还是此错误,无奈只好重启机器。重启后登陆服务器,查看/var/log这个目录下确实没有lastlog这个文件。查看/var/log/secure发现如下错误

    May 28 20:27:42 lxy sshd[3470]: Accepted password for root from 123.234.345.456 port 62130 ssh2
    May 28 20:27:42 lxy sshd[3470]: pam_unix(sshd:session): session opened for user root by (uid=0)
    May 28 20:27:43 lxy sshd[3472]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
    May 28 20:27:43 lxy sshd[3472]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory

只能手动建立这个文件了。使用如下命令建立

# touch /var/log/lastlog
# chgrp utmp /var/log/lastlog
# chmod 664 /var/log/lastlog

从日志中发现还有很多尝试登陆ssh的记录,估计是有人扫描。这种情况,建议对机器安全性进行一下检查,封锁一些不必要的账号,关闭一些不必要的服务,更改一下ssh的端口。