Ubuntu login信息的背后

当以非图形方式登录入Ubuntu系统时,总会有一些信息,比如软件包升级情况,显示在屏幕上,比如:


The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is c7:25:b4:11:55:95:c5:c2:80:ef:22:f2:9e:5a:95:cf.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
zhi@localhost's password: 
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

*** /dev/sda1 will be checked for errors at next reboot ***

Last login: Fri Nov 30 20:32:09 2012
zhi@ubuntu-desktop:~$ 

它们是怎么被显示出来的呢?经过调查,我查明背后使用的机制pam。
首先在/etc/pam.d/sshd中有:


……

# Print the message of the day upon successful login.
session optional pam_motd.so # [1]
……


pam_motd.so会显示/etc/motd中内容,/etc/motd的内容为:

Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-37-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

0 packages can be updated.
0 updates are security updates.

*** /dev/sda1 will be checked for errors at next reboot ***


实际上/etc/motd是每次登录时由脚本生成的,它是一个符号链接,指向/var/run/motd文件。


生成它的是/etc/update-motd.d下的一系列文件:

/etc/update-motd.d
/etc/update-motd.d/00-header
/etc/update-motd.d/10-help-text
/etc/update-motd.d/90-updates-available
/etc/update-motd.d/91-release-upgrade
/etc/update-motd.d/98-fsck-at-reboot
/etc/update-motd.d/98-reboot-required
/etc/update-motd.d/99-footer

update-motd是Ubuntu引入的一种机制,运行"man update-motd"可以得到更多信息。
到此,大部分清楚了,还有一个小尾巴,就是这一行:


Last login: Fri Nov 30 20:32:09 2012

本文给出的例子是用ssh登录的,这一行是由sshd的配置文件/etc/ssh/sshd_config决定的,具体地说是这一行

PrintLastLog yes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值