您的位置:首页 > 其它

Ubuntu login信息的背后

2013-07-07 21:08 155 查看
当以非图形方式登录入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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: