この記事では、ユーザーが次回のログイン時にパスワードを変更できるようにする方法について説明します。
これは、chage
のいずれかを使用して行うことができます (年齢を変更)またはpasswd
(パスワード)コマンド。
次の例は、ユーザーを作成し、chage
を使用する方法を示しています。 パスワードの変更を強制するコマンド:
Create user:
~]# useradd testuser1
[root@localhost ~]# passwd testuser1
Changing password for user testuser1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Set expiration:
~]# chage -d 0 testuser1
Testing:
~]$ su - testuser1
Password:
You are required to change your password immediately (administrator enforced)
Current password:
New password:
Retype new password:
[testuser1@localhost ~]$
passwd
次の例は、ユーザーを作成し、passwd
のみを使用する方法を示しています。 パスワードの変更を強制するコマンド:
Create user:
~]# useradd testuser2
~]# passwd testuser2
Changing password for user testuser2.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
Set expiration:
[root@localhost ~]# passwd -e testuser2
Expiring password for user testuser2.
passwd: Success
Testing:
~]$ su - testuser2
Password:
You are required to change your password immediately (administrator enforced)
Current password:
New password:
Retype new password:
[testuser2@localhost ~]$
どちらのオプションでも、ユーザーは次回ログイン時にパスワードを変更する必要があります。