web-dev-qa-db-ja.com

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

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

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:::

Ubuntuで--disabled-loginは正確に何をしますか?

16
spuder

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

--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::::::

wikipedia 簡単に説明します。 *と!効果的に同じことを行います。ユーザーがログインできないようにします(ただし、別のユーザーからのsuはできません)

17
spuder

shadowのmanページで部分的に説明されています。

抜粋

$ 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のmanページのバージョンに応じて、そこで参照されます。

抜粋 adduser man page

--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.
3
slm