Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

介绍

...

添加新用户需要修改image的bb文件,该文件在sources我们的标准镜像只有root用户,且该用户的密码为空,这个是由build/meta-yogurt/recipes-images/images目录下,

phytec-headless-image对应的bb文件是phytec-headless-image.bb,

phytec-qt5demo-image对应的bb文件是phytec-qt5demo-image.bb,

conf/local.conf文件中的

Code Block
languagebash
themeMidnight
# - "Makes an image suitable for development (e.g. allows root logins without
#    passwords and enables post-installation logging)"
EXTRA_IMAGE_FEATURES += "debug-tweaks"

配置的,此时不管是ssh还是串口,root用户都可以输入空密码登录。

如果去掉上面这个配置,则如果密码为空,就不能在ssh,串口等登录。

下面介绍怎样在yocto中修改用户信息,以实现编译出来的镜像就已经有修改好的用户信息。

在开发板上直接修改的方法和其他linux平台的命令行改法是一样的,可以使用useradd等命令。

BSP中修改用户信息

在yocto中修改用户信息有两种方法,如下:

方法local.conf文件改法layer的bb/bbappend文件改法
配置文件增加内容

...


Code Block
languagebash
themeMidnight

...

INHERIT += "extrausers"

EXTRA_USERS_PARAMS = "

...

\
usermod -P [password] 

...

其中[password]改为对应用户密码,[username]改为对应用户名。

如果要修改root的密码可以用以下的方法。

root; \
"



Code Block
languagebash
themeMidnight
inherit extrausers

EXTRA_USERS_PARAMS = "\
usermod -P 

...

[password] root; \
"

...


临时试一下推荐修改local.conf,正式开发在layer中修改比较好。

项目指令
增加root密码


Code Block
languagebash
themeMidnight

...

usermod -P [password] root;


增加用户


Code Block
languagebash
themeMidnight
useradd -

...

P [password] [username];


增加组


Code Block
languagebash
themeMidnight
groupadd developers;


用户删除


Code Block
languagebash
themeMidnight
userdel nobody;

更多信息

...