web-dev-qa-db-ja.com

ユーザー(Ubuntu)のパスワードポリシー情報を表示する方法

buntuドキュメント> Ubuntu 9.04> Ubuntuサーバーガイド>セキュリティ>ユーザー管理 Ubuntuにはデフォルトの最小パスワード長があると記載されています。

デフォルトでは、Ubuntuでは4文字以上のパスワードが必要です。

ユーザーがpasswdを使用してパスワードを変更するとします。ユーザーの現在のパスワードポリシーを表示するコマンドはありますか(chageコマンドは特定のユーザーのパスワードの有効期限情報を表示します)?

> Sudo chage -l SomeUserName
Last password change                                : May 13, 2010
Password expires                                    : never
Password inactive                                   : never
Account expires                                     : never
Minimum number of days between password change      : 0
Maximum number of days between password change      : 99999
Number of days of warning before password expires   : 7

これは、プロセスにエラーが含まれている可能性があるため、ポリシーを制御するさまざまな場所を調べて解釈するのではなく、構成されたポリシーを報告するコマンドは、ポリシー設定手順を確認するために使用されます。

5
CW Holeman II

OPは、policypassword lengthの2つの異なる質問を混同します。

@BillThorですでに述べたように、パスワードの長さは、次の行を含むファイル/etc/pam.d/common-password内の、それほど縁起の悪いキーワードobscureの下でPAMモジュールによって処理されます。

 password        [success=1 default=ignore]      pam_unix.so obscure sha512

obscureキーワードは(man pam_unixによる)の略です。

 obscure
       Enable some extra checks on password strength. These checks are based on the "obscure" checks in the
       original shadow package. The behavior is similar to the pam_cracklib module, but for
       non-dictionary-based checks. The following checks are implemented:

       Palindrome
           Verifies that the new password is not a palindrome of (i.e., the reverse of) the previous one.

       Case Change Only
           Verifies that the new password isn't the same as the old one with a change of case.

       Similar
           Verifies that the new password isn't too much like the previous one.

       Simple
           Is the new password too simple? This is based on the length of the password and the number of
           different types of characters (alpha, numeric, etc.) used.

       Rotated
           Is the new password a rotated version of the old password? (E.g., "billy" and "illyb")

obscureによる処方は、次のようにオーバーライドできます。/etc/pam.d/common-passwordで、上記の行を次のように書き換えます。

 password        [success=1 default=ignore]      pam_unix.so obscure sha512 minlen=20

またはあなたが好きなもの。

最小の長さのパスワードが定義されている場所を正確に見つけるには、pamの深さを調べる必要があります。

  # apt-cache search pam_unix.so
    libpam-modules - Pluggable Authentication Modules for PAM
  # apt-get source libpam-modules

...次に、パスワードの最小長が定義されている場所を見つけます。

  # grep -rl UNIX_MIN_PASS_LEN
    modules/pam_unix/support.h
    modules/pam_unix/support.c
    debian/patches-applied/007_modules_pam_unix
    debian/patches-applied/055_pam_unix_nullok_secure

Debianパッチを熟読すると、パラメータUNIX_MIN_PASS_LEN(27番目の可能なパラメータ)が/ modules/pam_unixに設定されているminlenという変数に対応していることがわかります。 /support.c。ただし、Debianパッチの1つでpass_min_lenが修正されました。ファイルdebian/patchs-applied/007_modules_pam_unixには次の行が含まれています。

 -       int pass_min_len = 0;
 +       int pass_min_len = 6;

そしてファイルdebian/Changelogは以下を指定します:

  • 007_modules_pam_unixのさらなるクリーンアップ-pass_min_lenにグローバル変数を使用しないでください。また、長さチェックを「あいまいな」チェックに不当に移動したり、エラー文字列を国際化したりしないでください。

私はいつもPAMが嫌いでした。そのため、パスワードの最小長などの些細なパラメータを見つけるには、ソースコードを調べる必要があります。

chage -l usernameによって表示される情報は、代わりに/ etc/shadowファイルに完全に含まれています。 マニュアルページ は次のように述べています。

shadowは、システムのアカウントのパスワード情報とオプションのエージング情報を含むファイルです。

各エントリのフィールドは次のとおりです。

ログイン名、暗号化されたパスワード、最後にパスワードを変更した日付、パスワードの最小有効期間、パスワードの最大有効期間、パスワード警告期間、パスワードの非アクティブ期間、アカウントの有効期限、および将来使用するための予約済みフィールド。

念のため、straceコマンドのchageは、開いているファイルを示しています。

 # strace -e trace=open -f chage -l myusername
   open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
   open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3                                                                                                                                                                                                               
   open("/proc/filesystems", O_RDONLY)     = 3                                                                                                                                                                                                                                    
   open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3                                                                                                                                                                                                                 
   open("/etc/passwd", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW) = 3                                                                                                                                                                                                               
   open("/etc/shadow", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW) = 4                                                                                                                                                                                                               
   open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 5                                                                                                                                                                                                                 
   open("/usr/share/locale/en_US/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such      file or directory)                                                                                                                                                                        
   open("/usr/share/locale/en/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory)                                                                                                                                                                           
   open("/usr/share/locale-langpack/en_US/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory)                                                                                                                                                               
   open("/usr/share/locale-langpack/en/LC_MESSAGES/shadow.mo", O_RDONLY) = -1 ENOENT (No such file or directory)                                                                                                                                                                  
   open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 5                                                                                                                                                                                                                                 
   Last password change                                    : mag 05, 2014                                                                                                                                                                                                         
   Password expires                                        : never                                                                                                                                                                                                                
   Password inactive                                       : never                                                                                                                                                                                                                
   Account expires                                         : never                                                                                                                                                                                                                
   Minimum number of days between password change          : 0                                                                                                                                                                                                                    
   Maximum number of days between password change          : 99999                                                                                                                                                                                                                
   Number of days of warning before password expires       : 7                                                                                                                                                                                                                    
   +++ exited with 0 +++                                                 
5
MariusMatutiae

ポリシーは/etc/pam.d/common-passwordにあります。デフォルトのポリシーはあいまいであり、pam_unixのマニュアルページに記載されています。 pam_cracklibをインストールして、いくつかの追加ポリシーを追加することができます。ルートによるパスワードの変更は、通常、ポリシーを回避します。

Pamを使用して新しいパスワードを確認していない場合、ポリシーはパスワードの変更に使用されるツールに属します。これは、LDAPまたは別の外部パスワードデータベースを使用していて、データベースで直接パスワードを変更している場合に発生する可能性があります。

2
BillThor