linux - enabling system user to login?

6

2

This user was created using this command:

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

But now I want that user to be able to login. I can become that user using sudo, but also would like to directly log in using password. I tried using this command:

sudo passwd user

It lets me add password for user. When I try to login, it logins but instantly exits.

Andrius

Posted 2015-06-10T13:51:08.200

Reputation: 477

Do you think you can get the picture of /etc/passwd now? – Farrukh Sadykov – 2015-06-11T02:08:31.007

Answers

7

You can not log in as user because it is a system account, which is specified by the --system option. System accounts are for daemons or services, not for human users, and are therefore given /bin/false for login shell. If you enter grep '^user' /etc/passwd, you will get something like this:

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

To allow user to log in, you can use usermod to change its login shell to bash:

usermod -s /bin/bash user

Alternatively, you can also edit /etc/passwd by hand. You may also want to make some other changes to user's UID, GID, and home directory location.

Larssend

Posted 2015-06-10T13:51:08.200

Reputation: 2 941

0

sounds like user is lock, try

usermod -U user

also have a look at /etc/shadow, line with user must start like this

 user:$6$SALT...

If the line is

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

then account is locked.

Archemar

Posted 2015-06-10T13:51:08.200

Reputation: 1 547

0

It might be that the user was created without the -m flag.

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

Edit: Also, see this answer to another question.

Lan

Posted 2015-06-10T13:51:08.200

Reputation: 11