星期五, 元月 08, 2010

Linux ssh 選端登入訊息 查看、修改

Ubuntu Linux (Server版)在 ssh 登入後, 會秀出下述訊息: (cat /etc/motd # 亦可看到)

Linux desktop 2.6.28-14-server #47-Ubuntu SMP Sat Jul 25 02:03:55 UTC 2009 x86_64

To access official Ubuntu documentation, please visit:
http://help.ubuntu.com/

  System information as of 二  1月  5 23:00:48 CST 2010

  System load: 0.02               Memory usage: 30%   Processes:       152
  Usage of /:  9.4% of 732.45GB   Swap usage:   26%   Users logged in: 0

  => There is 1 zombie process.

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

*** System restart required ***
No mail.
Last login: Tue Jan  5 11:49:45 2010 from user-desktop.local

但是在 Debian Linux 或 一般Ubuntu Desktop 都沒看到這些訊息, 於是來找找是怎麼產生的.

註: /etc/motd 是已經產生好的文字內容, 由此看不出任何東西.

ssh 遠端登入訊息

  • ssh 遠端登入的訊息內容, 是由 /etc/motd 呈現的.
  • 於每次登入時, /etc/motd 這個檔案就會被修改一次.(由此可見不是由 crontab 修改, 而是於每次登入時, 自動修改此檔案)

ssh 遠端登入 執行步驟

由於是每次登入時, 自動修改 /etc/motd, 於是找到下述:

  • vim /etc/pam.d/sshd
    # Print the message of the day upon successful login.
    session    optional     pam_motd.so # [1]
  • 看起來是 PAM 做的, 詳見: pam_motd - display the motd file

pam_motd.so 執行程式

pam_motd.so 會執行哪些程式就沒去追了, 由 motd 倒是直接找到產生 /etc/motd 的程式、執行順序. 

於 /etc/update-motd.d/ 的目錄, 找到 00 ~ 99 開頭的檔案, 於是試著執行看看(從 00-header 執行到 99-reboot-required), 就會看到 /etc/motd 的資訊了.

註: 從 00 執行到 99, /etc/motd 就產生出來了. :)

  • ls /etc/update-motd.d/
    00-header
    50-landscape-sysinfo
    90-updates-available
    91-release_upgrade
    99-reboot-required

關於 update-motd 的筆記

  1. 00-header - 此程式會執行 "uname -snrvm" 取得 CPU、與系統資訊 等.
  2. /usr/share/landscape/landscape-sysinfo.wrapper # 取得系統資源狀態、zombile 等訊息.
  3. /etc/motd.tail # 結尾補上 ubuntu 的廣告資訊. XD
  4. 註1: /usr/share/landscape/landscape-sysinfo.wrapper 的內容主要是 由此 /usr/bin/landscape-sysinfo 的 python script 產生的.
  5. 註2: /usr/bin/landscape-sysinfo 需安裝 landscape-common 的套件 (apt-get install landscape-common)

相關標籤

this is comment icon [回覆]

*** System restart required ***這條是要重開機嗎??

Comment by 呆兔^^ (01/16/2010 00:22)

this is comment icon 回 呆兔^^ [回覆]

嗯, 通常是 kernel 有更新, 提醒你要重開機~ :)

Comment by Tsung (01/16/2010 00:25)

this is comment icon [回覆]

可是我只是apt- get install 了一些東西像smarttools
那 kernel 也會變不同嗎???

想說會不會ubuntu 不夠耐操??

Comment by 呆兔 (01/16/2010 17:52)

this is comment icon 回 呆兔 [回覆]

不會不同, 應該是你安裝完時, 有選說安全性更新自動安裝, 然後安全性更新有更新 kernel.
so, 應該是這樣子造成的. :)

Comment by Tsung (01/16/2010 18:19)
Add this page to del.icio.us

發表迴響

標題

內容 (限制 1000 字)

暱稱

電子郵件

個人網頁


 authimage


PS: 若無法留言, 請先確認是否有打開 JavaScript, 造成您的困擾, 實在萬分對不起 Orz...(如果無法留言, 勞煩可以發信給我好嗎? 謝謝.)
PS2: 若您的留言被誤判, 我都會再自行看過, 不需要一直重覆張貼~