2009年8月5日 星期三

HP-UX 的 /etc/shadow File

 在 HP-UX 系統中,預設並沒有這個檔案,意味著密碼是存放在 /etc/passwd 中,而 /etc/passwd 這個檔案的預設權限為 r--r--r--,任何人都可以讀取,所以會有被 Hackers 破解密碼的風險存在。

 也許有人會想說將 /etc/passwd 的權限改為一般人不能讀取就好了,但修改權限並不是一個很好的解決方法,會造成許多程式無法正常運作,因為許多程式需要讀取 /etc/passwd 中的資料,查詢帳號與 UID 或 GID 的對應關係。


 Shadow System 能夠將 /etc/passwd 中與密碼相關的資訊搬移到另一個 /etc/shadow 檔案中,而這個檔案僅有 root 帳號能夠讀取,其他使用者帳號資訊仍保留在 /etc/passwd 中,這樣就能加強密碼的保護,而不會對其他程式造成影響。


 /etc/shadow (r--------) 格式如下:
user1:AdOKe9Eb2I37H:12345:60:120:14:30::

 User:Encrypted: Last :Min:Max:Warn:Inactive:Expiration:Reserved
Name Password Changed Days Days Days  Days


設定 Shadow 密碼
================
  • 預設 /etc/shadow 檔案是不存在的,Shadow 密碼在 11i v2 及 11i v3 已支援,11i v1 則需從 HP 網站上下載安裝。
  • 可以使用 swlist 指令來確認是否已安裝 shadow 套件。
   # swlist ShadowPassword
  • 執行 pwck 指令,先驗證 /etc/passwd 目前的內容格式是否正確。
   # pwck
  • 執行 pwconv 指令,可將 /etc/passwd 中的密碼搬移到 /etc/shadow。
   # pwconv
   *Warning*: There is a restriction on the use of shadow password functionality in this release of HP-UX. Failure to consider this limitation may lead to an inability to log in to the system after the conversion is performed. A system converted to use shadow passwords is not compatible with any repository other than files and ldap. This means that the passwd entry in the nsswitch.conf file must not contain nis, nis+, or dce.


   would you like to proceed with the conversion? (yes/no): yes

  • 當轉移成功後,/etc/passwd 中原本密碼的欄位應該已經變為 " x ”。
  • 若要將 /etc/shadow 的密碼搬移回原本 /etc/passwd 中,則執行 pwunconv 指令。
   # pwunconv


Username
==========
  • 此欄位必須與 /etc/passwd 中的 username 欄位名稱一致。
  • 在 11i v3 中 /etc/shadow 也支援 /etc/passwd 長度 255 個字元的使用者名稱。
Password
=========
  • 當你轉移為 Shadow 系統時,/etc/passwd 中的密碼欄位將被 " x " 所取代,而已加密過的密碼已被搬移到 /etc/shadow 密碼欄位中。
  • 假如此欄位為空值,則表示不需輸入密碼即可登入系統。
  • 如果要禁止帳號登入,則在此欄位中輸入 " * " 即可。
Last changed
=============
  • 密碼最後一次變更時間,但它的顯示方式不是以日期,而是以一組數字,這個數字是從 1970/1/1 開始到最後一次變更日期的天數。
Min days
========
  • 變更密碼後,新密碼至少保留多少天不可再變更密碼。

Max days
=========
  • 密碼多少天後過期。
  • 當 Min days 與 Max days 皆為 " 0 " 時,表示下次登入必須變更密碼。
  • 當 Min days  > Max days 時,表示密碼不可變更。
  • 這些限制不適用於 Super User。
Warn days==========
  • 密碼過期前多少天通知使用者。
Inactivity days==============
  • 當 Max days 值到期後,若還沒變更密碼,還有多少天可以登入,一旦超過 Inactivity days 天數,帳號將會鎖定。
  • 所以帳號可使用天數為 Max days + Inactivity days。
  • 此欄位設為 " 0 ",使用者必須變更密碼。
  • 在 HP-UX 系統,僅適用 Trusted System 中。
Expiration
==========

  • 帳號失效日期。
  • 與 Last changed 一樣,都是從 1970/1/1 開始算,到失效日期的天數。
Reserved=========
  • 此欄位為保留。

 此 /etc/shadow 檔案不建議手動編輯,建議使用 useraddusermoduserdel 和 passwd 指令管理使用者帳號。

沒有留言:

張貼留言