0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] ユーザーのログイン制御について②

Posted at

この記事について

ユーザーアカウントのログイン制御方法として、ユーザーのパスワードロックによる方法をまとめてみる。

コマンドによるロック

以下の方法では、各コマンドによりユーザーのパスワードをロックし、ログインの制御を行う。

usermod の場合

  • usermod -L を実行し、ユーザーのパスワードをロックする。
  [root@localhost ~]# usermod -L Kotaro
[sss_cache] [sysdb_domain_cache_connect] (0x0010): DB version too old [0.23], expected [0.24] for domain implicit_files!
Higher version of database is expected!
In order to upgrade the database, you must run SSSD.
Removing cache files in /var/lib/sss/db should fix the issue, but note that removing cache files will also remove all of your cached credentials.
Could not open available domains
[sss_cache] [sysdb_domain_cache_connect] (0x0010): DB version too old [0.23], expected [0.24] for domain implicit_files!
Higher version of database is expected!
In order to upgrade the database, you must run SSSD.
Removing cache files in /var/lib/sss/db should fix the issue, but note that removing cache files will also remove all of your cached credentials.
Could not open available domains
  • /etc/shadow ファイルを確認し、当該ユーザーのパスワードがロックされていることを確認する。
[root@localhost ~]# cat /etc/shadow | grep Kotaro
Kotaro:!$6$E7r54BMiEk2Wh8IK$uaDcgUIOKrnHOf7jHoGhIg5i.0jZe6iGnNYejflxFFZd7PiVj9Hl.P4.KVIVP0rPSR3cP58xMzdBVMLdGesBe.:20192:3:7:7::20198:

パスワードの先頭に存在する「!」は、ユーザーのパスワードがロックされていることを意味する。

  • 当該ユーザーでサーバーにログインを行う。パスワードロックの設定により、ログインに失敗する。
    image.png

  • サーバーでログを確認する。

Apr 15 18:11:45 localhost.localdomain sshd[3346]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.15.101  user>
Apr 15 18:11:45 localhost.localdomain unix_chkpwd[3348]: password check failed for user (Kotaro)

あくまでもパスワードのロックであるため、パスワード認証の失敗によるログイン不可であることがわかる。

  • usermod -U を実行し、当該ユーザーのパスワードロックを解除する。
[root@localhost ~]# usermod -U Kotaro
[sss_cache] [sysdb_domain_cache_connect] (0x0010): DB version too old [0.23], expected [0.24] for domain implicit_files!
Higher version of database is expected!
In order to upgrade the database, you must run SSSD.
Removing cache files in /var/lib/sss/db should fix the issue, but note that removing cache files will also remove all of your cached credentials.
Could not open available domains
[sss_cache] [sysdb_domain_cache_connect] (0x0010): DB version too old [0.23], expected [0.24] for domain implicit_files!
Higher version of database is expected!
In order to upgrade the database, you must run SSSD.
Removing cache files in /var/lib/sss/db should fix the issue, but note that removing cache files will also remove all of your cached credentials.
Could not open available domains
  • /etc/shadow ファイルを確認し、当該ユーザーのパスワードがロックが解除されていることを確認する。
[root@localhost ~]# cat /etc/shadow | grep Kotaro
Kotaro:$6$E7r54BMiEk2Wh8IK$uaDcgUIOKrnHOf7jHoGhIg5i.0jZe6iGnNYejflxFFZd7PiVj9Hl.P4.KVIVP0rPSR3cP58xMzdBVMLdGesBe.:20192:3:7:7::20198:

パスワードの先頭に存在していた「!」が消えている。パスワードのロックが解除されていることを意味する。

passwd の場合

  • passwd -l を実行し、ユーザーのパスワードをロックする。
    usermod によるロックと比較して、ロックに成功したことがシンプルでわかりやすい。
[root@localhost ~]# passwd -l Kotaro
Locking password for user Kotaro.
passwd: Success
  • /etc/shadow ファイルを確認し、当該ユーザーのパスワードがロックされていることを確認する。
[root@localhost ~]# cat /etc/shadow | grep Kotaro
Kotaro:!!$6$E7r54BMiEk2Wh8IK$uaDcgUIOKrnHOf7jHoGhIg5i.0jZe6iGnNYejflxFFZd7PiVj9Hl.P4.KVIVP0rPSR3cP58xMzdBVMLdGesBe.:20192:3:7:7::20198:

パスワードの先頭に存在する「!!」は、パスワードがロックされていることを意味する。usermodでのロックに対して、「!」の数が2つである。

  • 当該ユーザーでサーバーにログインを行う。パスワードロックの設定により、ログインに失敗する。
    image.png

  • サーバーでログを確認する。usermodでのロックと同じく、パスワード認証の失敗によるログイン不可であることがわかる。

Apr 15 18:33:08 localhost.localdomain sshd[3369]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.15.101  user>
Apr 15 18:33:08 localhost.localdomain unix_chkpwd[3371]: password check failed for user (Kotaro)
  • passwd -u を実行し、当該ユーザーのパスワードロックを解除する。
[root@localhost ~]# passwd -u Kotaro
Unlocking password for user Kotaro.
passwd: Success
  • /etc/shadow ファイルを確認し、当該ユーザーのパスワードがロックが解除されていることを確認する。
[root@localhost ~]# cat /etc/shadow | grep Kotaro
Kotaro:$6$E7r54BMiEk2Wh8IK$uaDcgUIOKrnHOf7jHoGhIg5i.0jZe6iGnNYejflxFFZd7PiVj9Hl.P4.KVIVP0rPSR3cP58xMzdBVMLdGesBe.:20192:3:7:7::20198:

パスワードの先頭に存在していた「!!」が消えている。パスワードロックが解除されたことを意味する。

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?