`adduser --disabled-login`は何をしますか?


16

私がフォローしているインストールドキュメントは、次のようにユーザーを追加するように指示します。

sudo adduser --disabled-login --gecos 'GitLab' git

--disabled-loginフラグは、私が検索しましたほとんどのmanページには存在しません。

2人のユーザーを作成しました。1人は--disabled-loginfoo)、もう1人は(git)です。

私が知る限り、--disabled-loginフラグは何もしません。私はまだsu両方のユーザーにでき、両方/bin/bashがログインシェルとして使用します。

私が見ることができる唯一の違いgetent passwdは、ログインが無効になっているユーザーのホームフォルダーの前に余分なコンマがあることです。これが何を意味するかを示すためのドキュメントはありません

root@gitlab:~# getent passwd git
git:x:998:998:GitLab:/home/git:/bin/bash  

root@gitlab:~# getent passwd foo
foo:x:1001:1002:GitLab,,,:/home/foo:/bin/bash

更新#1

私は別の違いを見つけました、1人のユーザーは*パスワードとして、もう1人は持っています!

root@gitlab:~# getent shadow git
git:*:15998::::::
root@gitlab:~# getent shadow foo
foo:!:15998:0:99999:7:::

--disabled-loginUbuntuで正確に何をしますか?


レコードの場合、「gecos」フィールド内のフィールドは、フルネーム、部屋番号、職場の電話番号、自宅の電話番号のカンマで区切られています。しかし、なぜあるバージョンに存在し、他のバージョンには存在しないのかはわかりません。これに関するドキュメントは、chfnツールのマンページにあります。
Random832

それは理にかなっている。ユーザーの1人を追加したときに、その情報の入力を求められたときに、誤って「y」を選択しました。他のユーザーはパペットを介して追加されました。
スパーダー

回答:


17

説明は十分に文書化されていません。

--disabled-loginはパスワードを !

パスワード値

NP or null = The account has no password
*  = The account is deactivated & locked
!  = The login is deactivated, user will be unable to login
!!  = The password has expired

root@gitlab:~# getent shadow vagrant
vagrant:$6$abcdefghijklmnopqrstuvwxyz/:15805:0:99999:7:::

root@gitlab:~# getent shadow foo
foo:!:15998:0:99999:7:::

root@gitlab:~# getent shadow git
git:*:15998::::::

ウィキペディアではこれについて簡単に説明しています。*および!効果的に同じことを行います。ユーザーがログインできないようにします(ただし、別のユーザーからsuを実行することはできません)


3

ここでは、shadowマニュアルページで部分的に説明されています。

抜粋

$ man shadow
...
...
encrypted password
     Refer to crypt(3) for details on how this string is interpreted.

     If the password field contains some string that is not a valid result of 
     crypt(3), for instance ! or *, the user will not be able to use a unix
     password to log in (but the user may log in the system by other means).

     This field may be empty, in which case no passwords are required to 
     authenticate as the specified login name. However, some applications which
     read the /etc/shadow file may decide not to permit any access at all if the
     password field is empty.

     A password field which starts with a exclamation mark means that the 
     password is locked. The remaining characters on the line represent the 
     password field before the password was locked.

マニュアルページのバージョンに応じて、adduserそこで参照されます。

adduser manページの抜粋

--disabled-login
       Do  not  run passwd to set the password.  The user won't be able
       to use her account until the password is set.

--disabled-password
       Like --disabled-login, but logins are still possible (for  exam-
       ple using SSH RSA keys) but not using password authentication.
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.