How to set the default root password
Contents
Introduction
By default on buildroot there is no password for root user. It is not really secure and can be a problem for some packages like dropbear. This page explain how to set a default password on our board.
On target
The straitforward way to set the root password is to login on the board then type :
# passwd Changing password for root New password: Bad password: too short Retype password: Password for root changed by root
If your password seems to be too simple for the system it will tell it, but the password is changed.
On host
If we have a big production of APF* to flash with the same default password it will be really painfull to change it on each boards. The best way is then to change it under your rootfs.
- First we need the debian/ubuntu package whois (wich is installed by default). Then générate the hash :
$ mkpasswd Mot de passe : 3DHrA1GdEo2u6
The hash for password 'toto' is generated. Then we have to put it in our shadow file under rootfs. To do that, edit your file buildroot/output/target/etc/shadow, and replace the line:
root::10933:0:99999:7:::
By
root:3DHrA1GdEo2u6:10933:0:99999:7:::
If you prefer bearded commands you can also type :
sed -i ’s%^root::%root:3DHrA1GdEo2u6:%’ $TARGETDIR/buildroot/output/target/etc/shadow
- Then regenerate your rootfs.
- You will then need a password for root when you will run your board.
Links
- Buildroot presentation of Thomas Petazzoni (page 25).