
該用戶是使用以下命令創建的:
sudo adduser --system --home=/opt/user --group user
但現在我希望該用戶能夠登入。我可以使用 成為該用戶sudo
,但也想直接使用密碼登入。我嘗試使用這個命令:
sudo passwd user
它允許我為用戶添加密碼。當我嘗試登入時,它登入但立即退出。
答案1
您無法登錄,user
因為它是由--system
選項指定的系統帳戶。系統帳戶用於守護程式或服務,而不是用於人類用戶,因此是/bin/false
為登入 shell 提供的。如果你輸入grep '^user' /etc/passwd
,你會得到類似這樣的資訊:
user:x:117:123::/opt/user:/bin/false
若要允許user
登入,您可以使用 usermod 將其登入 shell 變更為 bash:
usermod -s /bin/bash user
或者,您也可以/etc/passwd
手動編輯。您可能還想對user
的 UID、GID 和主目錄位置進行一些其他更改。
答案2
該用戶可能是在沒有 -m 標誌的情況下創建的。
-r, --system
Create a system account.
System users will be created with no aging information in /etc/shadow, and their numeric identifiers are choosen in the SYS_UID_MIN-SYS_UID_MAX range, defined in /etc/login.defs, instead of UID_MIN-UID_MAX (and their GID counterparts for the creation of groups).
Note that useradd will not create a home directory for such an user, regardless of the default setting in /etc/login.defs (CREATE_HOME). You have to specify the -m options if you want a home directory for a system account to be created.
-m, --create-home
Create the user's home directory if it does not exist. The files and directories contained in the skeleton directory (which can be defined with the -k option) will be copied to the home directory.
useradd will create the home directory unless CREATE_HOME in /etc/login.defs is set to no.
編輯:另外,請參閱這回答另一個問題。
答案3
聽起來用戶被鎖定,請嘗試
usermod -U user
也看看/etc/shadow
,使用者必須這樣開始
user:$6$SALT...
如果該行是
user:!!:..
user:*:...
然後帳戶被鎖定。