Linux幾個重要的安全性文件詳解

1./etc/passwd

Passwd文件由許多條記錄組成,每條記錄佔一行,記錄了一個用戶帳號的所有信息。每條記錄由7個字段組成,字段間用冒號“:”隔開,其格式如下:

username:password:User ID:Group ID:comment:home directory:shell

字段含義

  • username 用戶名
    它唯一地標識了一個用戶帳號,用戶在登錄時使用的就是它。

  • password 該帳號的口令
    passwd文件中存放的密碼是經過加密處理的。Linux的加密算法很嚴密,其中的口令幾乎是不可能被破解的。盜用帳號的人一般都藉助專門的***程 序,構造出無數個密碼,然後使用同樣的加密算法將其加密,再和本字段進行比較,如果相同的話,就代表構造出的口令是正確的。因此,建議不要使用生日、常用 單詞等作爲口令,它們在***程序面前幾乎是不堪一擊的。特別是對那些直接連入較大網絡的系統來說,系統安全性顯得尤爲重要。

  • User ID 用戶識別碼,簡稱UID。 
    Linux系統內部使用UID來標識用戶,而不是用戶名。UID是一個整數,用戶的UID互不相同。

  • Group ID 用戶組識別碼,簡稱GID。
    不同的用戶可以屬於同一個用戶組,享有該用戶組共有的權限。與UID類似,GID唯一地標識了一個用戶組。

  • comment 這是給用戶帳號做的註解
    它一般是用戶真實姓名、電話號碼、住址等,當然也可以是空的。

  • home directory 主目錄
    這個目錄屬於該帳號,當用戶登錄後,它就會被置於此目錄中,就像回到家一樣。一般來說,root帳號的主目錄是/root,其他帳號的家目錄都在/home目錄下,並且和用戶名同名。

  • login command 用戶登錄後執行的命令
    一般來說,這個命令將啓動一個shell程序。例如,用bbs帳號登錄後,會直接進入bbs系統,這是因爲bbs帳號的login command指向的是bbs程序,等系統登錄到bbs時就自動運行這些命令。

系統帳號

  系統中還有一些默認的帳號,如daemon、bin等。這些帳號有着特殊的用途,一般用於進行系統管理。這些帳號的口令大部分用(x)號表示,代表它們不能在登錄時使用。

2./etc/shadow

  /etc/passwd文件是任何人都可以讀的,那麼那些心有所圖的人就可以利用這個文件,使用各種各樣的工具按照Linux密碼加密的方法把用戶甚至root的密碼試出來,這樣整個系統就會被他所控制,嚴重危害系統的安 全和用戶數據的保密性。爲了增強系統的安全性,Linux系統還可以爲用戶提供MD5Shadow安全密碼服務。如果在安裝 Linux 時在相關配置的選項上選中了MD5和Shadow服務,那麼將看到的/etc/passwd文件裏的passwd項上無論是什麼用戶,都是一個“x”,這就表示這些用戶都登錄不了;系統其實是把真正的密碼數據放在了/etc/shadow文件裏。

/etc/shadow文件只能以具有管理員身份的用戶(root或者UID=1的用戶)來瀏覽,格式如下:

username:password:lastchg:min:max:warn:inactive:expire:flag

    The fields are defined as follows:

    username        The user's login name (UID).

    password        An encrypted password for the user generated
                    by crypt(3C), a lock string to indicate that
                    the login is not accessible, or  no  string,
                    which  shows  that  there is no password for
                    the login.

                    The lock string is defined as  *LK*  in  the
                    first four characters of the password field.

    lastchg         The number of days between January 1,  1970,
                    and  the  date  that  the  password was last
                    modified. The lastchg  value  is  a  decimal
                    number, as interpreted by atol(3C).

    min             The minimum number of days required  between
                    password  changes. This field must be set to
                    0 or above to enable password aging.

max             The maximum number of days the  password  is
                    valid.

    warn            The number of days before  password  expires
                    that the user is warned.

    inactive        The number of days of inactivity allowed for
                    that  user. This is counted on a per-machine
                    basis; the information about the last  login
                    is taken from the machine's lastlog file.

    expire          An absolute date expressed as the number  of
                    days since the Unix Epoch (January 1, 1970).
                    When this number is reached the login can no
                    longer be used. For example, an expire value
                    of 13514 specifies  a  login  expiration  of
                    January 1, 2007.

    flag            Failed login count in low order  four  bits;
                    remainder  reserved  for  future use, set to
                    zero.

有關命令

  • pwconv
    根據/etc/passwd文件生成/etc/shadow。它把所有口令從/etc/passwd移到/etc/shadow中。

  • pwunconv
    將/etc/shadow中的信息儘可能地恢復到/etc/passwd。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章