UbuntuにSSHでログインした際、
Using username "vagrant". Authenticating with public key "imported-openssh-key" from agent Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-55-generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Fri Jul 17 15:30:29 JST 2015 System load: 0.0 Users logged in: 1 Usage of /: 5.1% of 39.34GB IP address for eth0: 10.0.2.15 Memory usage: 4% IP address for eth1: 192.168.33.10 Swap usage: 0% IP address for docker0: 172.17.42.1 Processes: 118 Graph this data and manage this system at: https://landscape.canonical.com/ Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud *** System restart required ***
のような文字列が表示されます。この文字列をmotd(message of the day)といい、
Ubuntu14.04ではSSHログイン時にPAMを使用している場合、/etc/pam.d/sshdの中で、pam_motdモジュールを使用して、/run/motd.dynamicファイルに書かれているものを出力しています。
/run/motd.dynamicはプログラムによって生成されており、元となるデータは/etc/update-motd.dディレクトリに数字_ファイル名というスクリプトファイルで存在しています。数字順に実行していき、標準出力された文字列を/run/motd.dynamicに出力しています。
カスタマイズ例
- スクリプトファイルを作成
#!/bin/bash echo "custom message"
- /etc/update-motd.d内に設置
/etc/update-motd.d/99-hogehoge
- 実行権限付与
sudo chmod +x /etc/update-motd.d/99-hogehoge
- /run/motd.dynamicを更新
sudo sh -c "run-parts --lsbsysinit /etc/update-motd.d > /run/motd.dynamic"
- SSHで新しくログイン
Using username "vagrant". Authenticating with public key "imported-openssh-key" from agent Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-55-generic x86_64) * Documentation: https://help.ubuntu.com/ System information as of Fri Jul 17 15:49:35 JST 2015 System load: 0.19 Users logged in: 1 Usage of /: 5.3% of 39.34GB IP address for eth0: 10.0.2.15 Memory usage: 5% IP address for eth1: 192.168.33.10 Swap usage: 0% IP address for docker0: 172.17.42.1 Processes: 111 Graph this data and manage this system at: https://landscape.canonical.com/ Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 54 packages can be updated. 29 updates are security updates. *** System restart required *** custom message
↑ファイル名の数字部分を99にしたので、スクリプトで出力したものが一番最後に追加されている。
“Ubuntu 14.04でSSHログイン時のメッセージをカスタマイズ” への1件のフィードバック