FAQ:How do I set or change the root password: Difference between revisions
From Yocto Project
Jump to navigationJump to search
No edit summary |
(Create a function to change root password) |
||
Line 3: | Line 3: | ||
'''A:''' In the image.bb file (eg: core-image-minimal.bb), append this text:''' | '''A:''' In the image.bb file (eg: core-image-minimal.bb), append this text:''' | ||
ROOTFS_POSTPROCESS_COMMAND += "set_root_passwd;" | |||
ROOTFS_POSTPROCESS_COMMAND += " | set_root_passwd() { | ||
sed 's%^root:[^:]*:%root:wYNffsf6sozwE:%' \ | sed 's%^root:[^:]*:%root:wYNffsf6sozwE:%' \ | ||
< ${IMAGE_ROOTFS}/etc/shadow \ | < ${IMAGE_ROOTFS}/etc/shadow \ | ||
> ${IMAGE_ROOTFS}/etc/shadow.new; | > ${IMAGE_ROOTFS}/etc/shadow.new; | ||
mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ; | mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ; | ||
} | |||
This will set the root password as "root" in the newly built image. | This will set the root password as "root" in the newly built image. |
Revision as of 06:30, 24 June 2014
Q: How do I set / change the root password?
A: In the image.bb file (eg: core-image-minimal.bb), append this text:
ROOTFS_POSTPROCESS_COMMAND += "set_root_passwd;" set_root_passwd() { sed 's%^root:[^:]*:%root:wYNffsf6sozwE:%' \ < ${IMAGE_ROOTFS}/etc/shadow \ > ${IMAGE_ROOTFS}/etc/shadow.new; mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ; }
This will set the root password as "root" in the newly built image.
To choose a different password, use the command:
#passwd root
and copy the corresponding part of "/etc/shadow" to this text:
eg:
# cat /etc/shadow root:wYNffsf6sozwE:16122:0:99999:7::: ...