Ubuntu

Ubuntu 12.04 にsshでログインした時に表示されるメッセージ

Ubuntu 10.04 を 12.04 にアップグレードして運用中だが、どうも ssh でログインした時のメッセージが普通と違っているみたい。

VMwareで12.04環境を構築してsshでログインしたとき。

広告


Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-30-generic i686)

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

  System information as of Sat May 18 23:47:16 JST 2013

  System load:  0.0               Processes:           68
  Usage of /:   3.5% of 38.88GB   Users logged in:     1
  Memory usage: 7%                IP address for eth0: xxx.xxx.xxx.xxx
  Swap usage:   0%

  Graph this data and manage this system at https://landscape.canonical.com/

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

Last login: Sat May 18 23:02:18 2013 from hogeclient.hogedns.jp

運用環境にログインしたとき。(黄色のところの表示がない)

Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-43-generic i686)

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

Last login: Sat May 18 23:42:54 2013 from hogeclient.hogedns.jp

ずーっと追いかけて行くと、どうやら

/usr/bin/landscape-sysinfo  

等を使ってログイン時の情報が表示されるらしい。
(ログインするたびに /run/motd に書き込まれ、これが表示される)

ということで、以下をインストールする。

$ sudo apt-get install landscape-client-ui

これで情報を表示するスクリプトがインストールされる。

Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-43-generic i686)

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

  System information as of Sun May 19 00:06:12 JST 2013

  System load:  0.22               Processes:           199
  Usage of /:   79.9% of 72.42GB   Users logged in:     1
  Memory usage: 36%                IP address for eth1: xxx.xxx.xxx.xxx
  Swap usage:   9%

  Graph this data and manage this system at https://landscape.canonical.com/

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

Last login: Sat May 18 23:50:23 2013 from hogeclient.hogedns.jp

きっと過去の削除したのでしょう。なぜなら、10.04時代には古いマシンを使っており、ログイン時に待たされてイライラしていたから。面倒なので検証はしていないけれども・・・。

これをセットアップしたところ、長く原因がわからなかった以下のログが出力されなくなった。

May 12 08:48:47 hogehoge sshd[6838]: Accepted publickey for hogeuser from xxx.xxx.xxx.xxx port 49529 ssh2
May 12 08:48:47 hogehoge sshd[6838]: pam_unix(sshd:session): session opened for user hogeuser (uid=0)
May 12 08:48:49 hogehoge dbus[509]: [system] Rejected send message, 2 matched rules; type=”method_call”, sender=”:1.39″ (uid=1000 pid=3311 comm=”/usr/lib/ubuntu-geoip/ubuntu-geoip-provider “) interface=”org.freedesktop.NetworkManager” member=”GetPermissions” error name=”(unset)” requested_reply=”0″ destination=”org.freedesktop.NetworkManager” (uid=0 pid=811 comm=”NetworkManager “)
May 12 08:48:49 hogehoge dbus[509]: [system] Rejected send message, 2 matched rules; type=”method_call”, sender=”:1.41″ (uid=1000 pid=3362 comm=”/usr/lib/telepathy/mission-control-5 “) interface=”org.freedesktop.NetworkManager” member=”GetPermissions” error name=”(unset)” requested_reply=”0″ destination=”org.freedesktop.NetworkManager” (uid=0 pid=811 comm=”NetworkManager “)
May 12 08:48:50 hogehoge dbus[509]: [system] Rejected send message, 2 matched rules; type=”method_call”, sender=”:1.34″ (uid=1000 pid=3220 comm=”nm-applet “) interface=”org.freedesktop.NetworkManager” member=”GetPermissions” error name=”(unset)” requested_reply=”0″ destination=”org.freedesktop.NetworkManager” (uid=0 pid=811 comm=”NetworkManager “)

んー!すっきり!! 5/19に再発のため取り消し。

ちなみに、sshdの設定を変更すると、最終ログイン時間のみ表示されるようになる。

/etc/ssh/sshd_config

UsePAM no ←デフォルトはyes

$ sudo service ssh restart

結果。

Last login: Sun May 19 00:06:14 2013 from hogeclient.hogedns.jp

ということで、PAM認証の結果、/etc/motdが作られていることがわかる。

そしてUsePAMが何かというと、sshd_configの中にコメントがあって、

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.

だそうで、[ほぼ]Google先生の翻訳結果が

これを'yes'に設定するとPAM認証、アカウント処理、セッション処理が有効になります。

これが有効になっている場合は、PAM認証がChallengeResponseAuthenticationと
PasswordAuthenticationを介して許可されます。

PAMの構成に応じて、ChallengeResponseAuthentication経由のPAM認証は
"PermitRootLogin without-password"の設定をバイパスすることがあります。

あなたがPAMアカウントとセッションのチェックをPAM認証なしで実行したい場合は、
これを有効にして、しかしPasswordAuthenticationと
ChallengeResponseAuthenticationを'no'にしてください。

である。翻訳結果に手を加えているので正確なところは原文を見て欲しいが、でも最後の行の意味が全くわからない・・・。

さて、ログイン時に情報を表示したい場合は上記の通りパッケージをインストールすれば良いとして、消したい場合にはパッケージを消せばいいかというとそうでもなさそう。なぜなら、これを使っているらしいアプリケーションがあったりするから。

そこで、ログイン時のメッセージを作っているスクリプトを辿って探してみる。

lrwxrwxrwx 1 root root 13   5月 17 23:07 /etc/motd -> /var/run/motd

-rw-r--r-- 1 root root 509  5月 19 02:40 /var/run/motd

ということで・・・

$ su -
# find /etc -name \* | xargs grep "/var/run/motd"

何も見つからない。ということで、よく見れば

lrwxrwxrwx  1 root root        4  5月 18 09:33 run -> /run/

だったので・・・

# find /etc -name \* | xargs grep "/run/motd"
/etc/init/mounted-run.conf:    [ -d "/etc/update-motd.d" ] && run-parts --lsbsysinit /etc/update-motd.d > /run/motd &

これっぽい。

# ll /etc/update-motd.d
合計 36
drwxr-xr-x  2 root root 4096  5月 17 23:11 ./
drwxr-xr-x 86 root root 4096  5月 19 03:34 ../
-rwxr-xr-x  1 root root 1220  4月 19  2012 00-header*
-rwxr-xr-x  1 root root 1358  4月 19  2012 10-help-text*
lrwxrwxrwx  1 root root   46  5月 17 23:11 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper*
-rwxr-xr-x  1 root root  149  5月 16  2012 90-updates-available*
-rwxr-xr-x  1 root root  129  8月  9  2012 91-release-upgrade*
-rwxr-xr-x  1 root root  142  5月 16  2012 98-fsck-at-reboot*
-rwxr-xr-x  1 root root  144  5月 16  2012 98-reboot-required*
-rwxr-xr-x  1 root root 1158  4月 19  2012 99-footer*

#cat 50-landscape-sysinfo
・
・
    /usr/bin/landscape-sysinfo ←上の ※ のファイル
・
・

これらのスクリプトが必要に応じて実行され、ログイン時にmotdファイルを作っているようなので、これらをうまく整理すれば良さそう。

でも、検証する余裕なし。今日はこれまで。


2013/07/07追記。
その後、色々と情報を漁っていたらココに詳しく書かれている。
こちらの情報のほうが有益かな。

広告

コメントはこちらから お気軽にどうぞ ~ 投稿に関するご意見・感想・他