-1

I want to add a custom user to my OpenWRT image, so that when that image is flashed onto a board, it should have the custom user account.

I figured out that adding a user to /etc/shadow file will do the trick. But my doubt is how to set the password for the user. It seems there is an entry for password as well, but the password needs to be encrypted. How can I convert plain text password to encrypted.

Also I need to change the default 'root' password. I assume that there should be some way to alter the default 'root' password and give a new one.

NB: I need to do have a image with all these changes and do not want to do it by some script after the system boot

ssin
  • 25
  • 8

2 Answers2

1

I am assuming you are building your own custom images.

You can customize the image by creating files folder under buildroot. You can add files/folders to this folder which will be override the default files in the distributions. For example, you can take an existing OpenWRT installation and add the user(s) and set the passwords. You can also change the root password. Backup the /etc/passwd and /etc/shadow and copy them to '<buid_root>/files folder. The folder structure will look like this

<build_root>/files
<build_root>/files/etc/passwd
<build_root>/files/etc/shadow

You can use the above approach to customize the image. Please note that above files will overwrite the default files. If you have any other software(s) which needs user(s)/group(s), you may have to add them to the above files.

fossil
  • 740
  • 6
  • 17
0

When being logged via ssh as root you set a new password with passwd my_user and then copy the hash that passwd writes out to /etc/shadow. If you paste the same hash to another OpenWRT it will still work.

Then you do the same with passwd root.

kubanczyk
  • 5,184
  • 1
  • 41
  • 52