Implement a user and password with sudo permission

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Implement a user and password with sudo permission

114件の閲覧回数
Rabiraj
Contributor I

Hi,
I am using imx.8m.plus SOC using phytec SOM.
I need to add a user called newmachine with a password 1234rt
I need to have root login with a password
My user need to have sudo permission.
All these I need to do when I build the yocto image itself.
I tried several ways, but not sure what I am doing wrong.


Steps which I have followed :
I created my own machine .bb file, its working fine.
Then into that file I added,
below code,

inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -p '' newmachine ; "


Here without the password, I am able to access my device through ssh, via ethenet.
When I add password directly ( hardcoded ) or using mkpasswd - > like below, I am not able to access my device over ssh.

printf "%q" $(mkpasswd -m sha256crypt 1234rt)

 then final code looks like:

inherit extrausers
PASSWD = "\$5\$cAO0AZTEak0DE4Z9\$joF9Clj2kEG4XlRJbL5udiqX2yYL3ib9jXKsAsRngPD"
EXTRA_USERS_PARAMS = "\
    useradd -p '${PASSWD}' newmachine ; \
    "

 For changing root password, I tried as :

inherit extrausers
EXTRA_USERS_PARAMS = "\
    usermod -p '${PASSWD}' root; \
    "

 

I really don't know what is wrong here, I tried multiple experiments, and nothing was successful. 

For adding sudo permission for my user, I added the following:

EXTRA_USERS_PARAMS = "echo 'newmachine ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/newmachine "

 here the newmachine file does not exist, that is something I would like to note it down, so I even tried to add it in /etc/sudoers file, instead of echo to sudoers.d, like below

EXTRA_USERS_PARAMS = "echo 'newmachine ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers "

None of the above is working, please let me know, what am I missing.

0 件の賞賛
返信
0 返答(返信)