yocto实践之新增系统用户以及碰到的问题

在Yocto项目中,为了满足需求添加了额外用户,但遇到认证失败的问题。通过查阅文档发现,问题源于启用的`debug-tweaks`功能允许空密码登录,导致用户可以无密码切换。解决方案是修改配置,正确设置用户密码,并注释掉`debug-tweaks`,重新构建系统镜像后,用户切换恢复正常。
摘要由CSDN通过智能技术生成

背景:由于项目需求,需要在root用户之外,新增三权用户。由于安全相关功能尚未做好,所以提前以普通用户进行尝试。

查询原始的官方文档,其中有示例如下:

Here is an example that adds two users named “tester-jim” and “tester-sue” and assigns passwords:

inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -P tester01 tester-jim; \
    useradd -P tester01 tester-sue; \
    "

按照此例修改image的配置文件kylin-base.inc

inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -P 123123 test1; \
    "

生成的镜像烧录到板子上之后,切换用户test1,报错认证失败。查看/etc/passwd和/etc/shadow文件中,均有kylin相关的字样,代表用户确实添加进去了,但是无法切换。

最终添加用户部分修改如下

inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd test; \
    usermod -P 123123 test; \              #注意-P参数的大小写,此处为大写字母P

"

同样将生成的镜像烧录到板子,能够成功切换用户test,但是发现不需要输入密码了。

查询发现在配置文件base.yml中存在这样的一段:

EXTRA_IMAGE_FEATURES = "debug-tweaks tools-debug"

查询yocto官网文档发现如下解释:

allow-empty-password: Allows Dropbear and OpenSSH to accept root logins and logins from accounts having an empty password string.

dbg-pkgs: Installs debug symbol packages for all packages installed in a given image.

debug-tweaks: Makes an image suitable for development (e.g. allows root logins without passwords and enables post-installation logging). See the ‘allow-empty-password’, ‘empty-root-password’, and ‘post-install-logging’ features in this list for additional information.

dev-pkgs: Installs development packages (headers and extra library links) for all packages installed in a given image.

doc-pkgs: Installs documentation packages for all packages installed in a given image.

empty-root-password: Sets the root password to an empty string, which allows logins with a blank password.

package-management: Installs package management tools and preserves the package manager database.

post-install-logging: Enables logging postinstall script runs to the /var/log/postinstall.log file on first boot of the image on the target system.

原来是因为添加了debug-tweaks这个features导致的,在base.yml中将debug-tweaks先注释掉,重新生成系统镜像,

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值