cancel
Showing results for 
Search instead for 
Did you mean: 

New user from useradd not found on the /etc/passwd

vfranchi
Associate III

Hi all.

I am adding a new user to my Linux image. After generating the image I verify the `/etc/passwd` on the rootfs and the new user is not present. When I try to login to this new user on the running image itself, it doesn't work. As I am using the "read-only-rootfs" feature, I think some extra setup is required to fix this issue.

 

In order to build my recipe, I followed the instructions from useradd-example.bb .

How to add a new user properly with the read only rootfs feature?

 

PS. I am setting another partition on the /home. So this folder is writable.

 

Thanks

2 REPLIES 2
PatrickF
ST Employee

Hi @vfranchi ,

to add a new user, during a yocto training, we were using the following, but I'm far to be an expert:

# create password hash using openssl
openssl passwd -5 MY_PASSWORD
# you get a hash string in a form of $5$nnn...nnn$nnn...nnn

# add hash in my-image (prefix each $ by \)
gedit ../../layers/meta-my-layer/recipes-core/images/my-image.bb
	inherit core-image extrausers
	EXTRA_USERS_PARAMS += "useradd -p '\$5\$nnn...nnn\$nnn...nnn' MY_USERNAME;"

 

Hope this helps.

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @PatrickF 

Thank you for your reply.

I tried the `EXTRA_USERS_PARAMS` before, but it does not work due the read-only-rootfs option. I guess it is because Yocto adds the users after the rootfs recipe is done and then due the immutability it does not work. If I remove the read-only then it works just fine.

Regarding the `core-image` inherit  from your example, do you know if it causes the users to be added at another moment on the build?

Thank you.