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

> -----Original Message-----
> From: yocto-boun...@yoctoproject.org [mailto:yocto-
> boun...@yoctoproject.org] On Behalf Of David Andrey
> Sent: Wednesday, October 16, 2013 8:58 AM
> To: yocto@yoctoproject.org
> 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
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
_______________________________________________
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto

Reply via email to