得之我幸 失之我命

when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.

auth.log 不存在

事出突然

牵一发而动全身,在查 ssh 为啥无法公私钥认证登陆的图中,找到了开启 sshd_config DEBUG 模式,将认证过程的 log 记录在 auth.log 中

为了方便,我直接删除了 auth.log,想着它应该是会被重新生成的,结果意料之中的意料之外,它没有自己生成

那我就想着自己创建一个总行了吧,结果还是没有收集到任何的 debug 信息

auth.log 背景

Ubuntu Document 中的一段话

The Authorization Log tracks usage of authorization systems, the mechanisms for authorizing users which prompt for user passwords, such as the Pluggable Authentication Module (PAM) system, the sudo command, remote logins to sshd and so on. The Authorization Log file may be accessed at /var/log/auth.log. This log is useful for learning about user logins and usage of the sudo command.

从上面这段引用可以了解到,ubuntu 通过 /var/log/auth.log 文件可以查看一些关于 ssh 登陆、sudo 命令的信息

跟着别人的教程走

1
2
3
$ ps auxf | grep syslog  # 确认 rsyslog 进程是否正常运行
test 22054 0.0 0.0 21532 1036 pts/2 S+ 18:43 0:00 \_ grep --color=auto syslog
syslog 11674 0.0 0.0 368820 6812 ? Ssl 18:21 0:00 /usr/sbin/rsyslogd -n

上面的结果告诉我,这货不要太正常

1
2
3
4
5
6
$ vim /etc/rsyslog.d/50-default.conf  # 排查 rsyslog 的配置是否正确
#
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog

看得出来,谁都没动过

1
2
3
4
5
6
# 手动创建 auth.log
# touch /var/log/auth.log # 鉴于我前面已经自己创建过了,就不创建了
$ chmod 640 /var/log/auth.log # 我自己手动创建的时候忽略了这个
$ chown syslog.adm /var/log/auth.log # 我自己手动创建的时候没做这个
$ ls -la /var/log/auth.log
-rw-r----- 1 syslog adm 9396 11月 25 18:34 /var/log/auth.log

此外,我还重启了一下 syslog 服务,终于正常的见到了 auth.log 的内容

1
2
$ ls -l /var/ | grep log  # 人家的教程里还有一步这个检查,我也执行了,下述结果是正确的
drwxrwxr-x 15 root syslog 4096 11月 25 17:55 log

最后

还有一个结论,rsyslog 是正常工作的,但是没有创建 /var/log/auth.log

be slow to promise and quick to perform.