2018年2月1日木曜日

I see some messages from Ubuntu 16.04 using ssh login

I see some messages from Ubuntu 16.04 using ssh login as following:
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-112-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

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


Last login: Thu Feb  1 13:51:02 2018 from xx.yy.xx.yy
If you want to supress this message, you create .hushlogin file at your home directory. This .hushlogin file is reffered from login process. There is the description about this in man of login.
$ man login

       $HOME/.hushlogin
           Suppress printing of system messages.

$
This messges is created by scripts in /etc/update-motd directory.
Ubuntu 14.04でSSHログイン時のメッセージをカスタマイズ
https://mistymagich.wordpress.com/2015/07/17/ubuntu-14-04%E3%81%A7ssh%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E6%99%82%E3%81%AE%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8%E3%82%92%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA/

Ubuntu14.04ではSSHログイン時にPAMを使用している場合、/etc/pam.d/sshdの中で、pam_motdモジュールを使用して、/run/motd.dynamicファイルに書かれているものを出力しています。

/run/motd.dynamicはプログラムによって生成されており、元となるデータは/etc/update-motd.dディレクトリに数字_ファイル名というスクリプトファイルで存在しています。数字順に実行していき、標準出力された文字列を/run/motd.dynamicに出力しています。