GNU/Linux >> Linux の 問題 >  >> Linux

UNIX / Linux :パスワードがリセットされた後、次回のログイン時にユーザーにパスワードの変更を強制する方法

質問

ユーザーが次回ログインするときにパスワードを変更するように要求するにはどうすればよいですか?ユーザーは、パスワードがリセットされた後に初めてパスワードを強制的に変更する必要があります。

1.変更コマンドの使用

これは、-d を指定した chage コマンドを使用して実行できます オプション。変更のマニュアルページによると:

# man chage
....
-d, --lastday LAST_DAY
    Set the number of days since January 1st, 1970 when the password was last changed. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area). If the LAST_DAY is set to 0 the user is forced to change his password on the next log on.
...

ユーザーの最終パスワード変更日を 0 に設定するには、以下のコマンドを使用します:

# chage -d 0 [username]

たとえば、ユーザー (testuser) の最終パスワード変更日を chage コマンドで 0 に設定するには:

# chage -d 0 testuser

2. passwd コマンドの使用

ユーザーにパスワードの変更を強制する別の方法は、コマンド passwd を使用することです -e で オプション。 -e オプションを指定すると、現在のユーザー パスワードが期限切れになり、ユーザーは次回のログイン時に新しいパスワードを設定する必要があります。 passwd コマンドの man ページから:

-e     This is a quick way to expire a password for an account. The user will be forced to change the password during the next login  attempt. Available  to  root only.

現在のパスワードを失効させ、ユーザーに新しいパスワードの設定を強制するには、次のコマンドを使用します:

# passwd -e [username]

ユーザーが古いパスワードを覚えていない場合は、上記のコマンドを実行する前に passwd で一時的なパスワードを指定してください。

確認

次にユーザーが (古いパスワードを使用して) 認証を行うと、新しいパスワードの入力が強制されます。

# ssh testuser@localhost
testuser@localhost's password: 
You are required to change your password immediately (root enforced)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user testuser.
Changing password for testuser.
(current) UNIX password: 
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
Connection to localhost closed.

現在のパスワードの有効期限が切れているかどうかを確認するには、コマンド chage を使用しないでください .

# chage -l [username]


Linux
  1. Linuxでユーザーパスワードを変更、削除、または無効にする方法

  2. Linuxでユーザー名を変更する方法

  3. BashスクリプトにUnix/Linuxユーザーを追加する方法は?

  1. 次回のログイン時にパスワードを強制的に変更する

  2. Linuxでユーザーパスワードを設定または変更する

  3. ssh を使用して初めてログインするときに、ユーザーにパスワードの変更を強制するにはどうすればよいですか?

  1. Linuxの特定のTtynにログインした後、デフォルトのシェルを(永続的に)変更するにはどうすればよいですか?

  2. Linuxでユーザーパスワードを変更または設定する方法

  3. UNIX / Linux :パスワードがリセットされた後、次回のログイン時にユーザーにパスワードの変更を強制する方法