Linux: ¿permitir que el usuario del sistema inicie sesión?

Linux: ¿permitir que el usuario del sistema inicie sesión?

Este usuario fue creado usando este comando:

sudo adduser --system --home=/opt/user --group user

Pero ahora quiero que ese usuario pueda iniciar sesión. Puedo convertirme en ese usuario usando sudo, pero también me gustaría iniciar sesión directamente con una contraseña. Intenté usar este comando:

sudo passwd user

Me permite agregar contraseña para el usuario. Cuando intento iniciar sesión, inicia sesión pero sale instantáneamente.

Respuesta1

No puede iniciar sesión userporque es una cuenta del sistema, que se especifica en la --systemopción. Las cuentas del sistema son para demonios o servicios, no para usuarios humanos y, por lo tanto, se proporcionan /bin/falsepara el shell de inicio de sesión. Si ingresas grep '^user' /etc/passwd, obtendrás algo como esto:

user:x:117:123::/opt/user:/bin/false

Para permitir userel inicio de sesión, puede usar usermod para cambiar su shell de inicio de sesión a bash:

usermod -s /bin/bash user

Alternativamente, también puedes editar /etc/passwda mano. Es posible que también desee realizar otros cambios en userel UID, GID y la ubicación del directorio de inicio.

Respuesta2

Es posible que el usuario se haya creado sin el indicador -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.

Editar: también, veresterespuesta a otra pregunta.

Respuesta3

Parece que el usuario está bloqueado, inténtalo.

usermod -U user

También eche un vistazo a /etc/shadow, la línea con el usuario debe comenzar así

 user:$6$SALT...

Si la línea es

 user:!!:..
 user:*:...

entonces la cuenta está bloqueada.

información relacionada