Skip to contentSkip to conversation

default root password

DISCUSSION David Andrey 3 participants 5 messages Oct 16, 2013 – Oct 18, 2013

lore
Share & tools
lore
#1 lore raw

2013/10/16 David Andrey <[email protected]>

Quoted 6 lines

Hi,

There are lot of threads floating around, and a FAQ without answer.
https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root_p
assword

Quoted 7 lines

So what is the official way to set a default root password ? Using a sed command on /etc/passwd through ROOTFS_POSTPROCESS_COMMAND or is there any other built-in solution ?

regards
David

David,

Did you find another way to achieve this?

--
*dS
Diego Sueiro

/*long live rock 'n roll*/

Quoted 5 lines

_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#2 lore raw
In reply to David Andrey

David,

I've had similar issues, and this is what I've done to get the root password set properly in my image. I am using poky/Dylan-9.0.1 for a starting point.

1. In my case, I want a root password that is longer than 8 characters. With poky/dylan, it is using tinylogin for password management which has an issue with passwords longer than 8 characters; it looks like it is using them, but it only pays attention to the first 8 characters. If you want to use a root password that is longer than 8 characters, there is a 10 patch series under poky/master submitted by Chen Qi on 2013-06-25. Cherry-pick these 10 patches and apply them to your local poky repository. Rebuild your image with "debug-tweaks" set in local.conf.
2. Boot up your newly built image with the default blank password (or some other password you know what it is). Then, change the root password using the passwd command. If you want a root password that is longer than 8 characters, use "passwd -m".
3. Look at the contents of /etc/shadow. Everything between the first two colons on root's line is its password. For example, if it looked like this:

	root:$QAGQ$%Y#QTRAG%^J#$#QR$@:15924:0:99999:7:::

then $QAGQ$%Y#QTRAG%^J#$#QR$@ would be root's encrypted password. Copy that text.
4. Add the following to the end of your image recipe:

ROOTFS_POSTPROCESS_COMMAND += "\
    sed 's%^root:[^:]*:%root:<encrypted_password_goes_here>:%' \
        < ${IMAGE_ROOTFS}/etc/shadow \
        > ${IMAGE_ROOTFS}/etc/shadow.new;\
    mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ;"

and that will change root's password in your image.

I know there is the EXTRA_USER_PARAMS feature for adding users and modifying a user's password, but I couldn't get it to work for root. I tried adding:

INHERIT += "extrausers"

EXTRA_USERS_PARAMS = "\
    usermod -p '<encrypted_password_goes_here>' root; \
    "

and I would get errors when building the image. I can't remember the errors I got, but I couldn't get the build to complete when I tried to modify the root password in this manner. The other way worked so I went with that.

Hope that helps.

-Bryan Evenson

Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:yocto- [email protected]] On Behalf Of David Andrey
Sent: Wednesday, October 16, 2013 8:58 AM
To: [email protected]
Subject: [yocto] default root password

Hi,

There are lot of threads floating around, and a FAQ without answer.
https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root_
p
assword

So what is the official way to set a default root password ? Using a sed command on /etc/passwd through ROOTFS_POSTPROCESS_COMMAND or is there any other built-in solution ?

regards
David
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto

#3 lore raw

2013/10/17 Bryan Evenson <[email protected]>

Quoted 5 lines

I know there is the EXTRA_USER_PARAMS feature for adding users and modifying a user's password, but I couldn't get it to work for root. I tried adding:

INHERIT += "extrausers"

Quoted 9 lines
EXTRA_USERS_PARAMS = "\
    usermod -p '<encrypted_password_goes_here>' root; \
    "

and I would get errors when building the image. I can't remember the errors I got, but I couldn't get the build to complete when I tried to modify the root password in this manner. The other way worked so I went with that.

Bryan,

I've tried that too.The issue raised for me was related to INHERIT += "extrausers", as soon as, it is not present on dylan branch. So, I solved that with ROOTFS_POSTPROCESS_COMMAND strategy.

Regards,

--
*dS
Diego Sueiro

/*long live rock 'n roll*/

#4 lore raw
In reply to Bryan Evenson

Hi Bryan,

Solved this using the ROOTFS_POSTPROCESS_COMMAND, but without the patches series for > 8 characters password. Thanks for that input :-)

Using danny in this particular case.

Hope someone will update the FAQ !

Thanks
David

-----Original Message-----
From: Bryan Evenson [mailto:[email protected]]
Sent: jeudi 17 octobre 2013 15:23
To: David Andrey; [email protected]
Subject: RE: default root password

David,

I've had similar issues, and this is what I've done to get the root password set properly in my image. I am using poky/Dylan-9.0.1 for a starting point.

1. In my case, I want a root password that is longer than 8 characters. With poky/dylan, it is using tinylogin for password management which has an issue with passwords longer than 8 characters; it looks like it is using them, but it only pays attention to the first 8 characters. If you want to use a root password that is longer than 8 characters, there is a 10 patch series under poky/master submitted by Chen Qi on 2013-06-25. Cherry-pick these 10 patches and apply them to your local poky repository. Rebuild your image with "debug-tweaks" set in local.conf.
2. Boot up your newly built image with the default blank password (or some other password you know what it is). Then, change the root password using the passwd command. If you want a root password that is longer than 8 characters, use "passwd -m".
3. Look at the contents of /etc/shadow. Everything between the first two colons on root's line is its password. For example, if it looked like this:

	root:$QAGQ$%Y#QTRAG%^J#$#QR$@:15924:0:99999:7:::

then $QAGQ$%Y#QTRAG%^J#$#QR$@ would be root's encrypted password. Copy that text.
4. Add the following to the end of your image recipe:

ROOTFS_POSTPROCESS_COMMAND += "\
    sed 's%^root:[^:]*:%root:<encrypted_password_goes_here>:%' \
        < ${IMAGE_ROOTFS}/etc/shadow \
        > ${IMAGE_ROOTFS}/etc/shadow.new;\
    mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ;"

and that will change root's password in your image.

I know there is the EXTRA_USER_PARAMS feature for adding users and modifying a user's password, but I couldn't get it to work for root. I tried adding:

INHERIT += "extrausers"

EXTRA_USERS_PARAMS = "\
    usermod -p '<encrypted_password_goes_here>' root; \
    "

and I would get errors when building the image. I can't remember the errors I got, but I couldn't get the build to complete when I tried to modify the root password in this manner. The other way worked so I went with that.

Hope that helps.

-Bryan Evenson

Quoted 25 lines

-----Original Message-----
From: [email protected] [mailto:yocto- [email protected]] On Behalf Of David Andrey
Sent: Wednesday, October 16, 2013 8:58 AM
To: [email protected]
Subject: [yocto] default root password

Hi,

There are lot of threads floating around, and a FAQ without answer.
https://wiki.yoctoproject.org/wiki/FAQ:How_do_I_set_or_change_the_root
_
p
assword

So what is the official way to set a default root password ? Using a sed command on /etc/passwd through ROOTFS_POSTPROCESS_COMMAND or is there any other built-in solution ?

regards
David
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto