Raspberry PI: Create a (default) user during Raspian installation

Hi,

rasbian is no langer shipped with the default user pi. A new user must be created during the first logon at the console.


Unfortunately this makes a headless installation not possible.

Raspbian has a method to create a new user within the deployment process.

Here are the steps:

Download the latest image, unzip it, determine your SD Card, and flash the latest image

root@debdev ~/Downloads # fdisk -l
...
Festplatte /dev/sdc: 28,93 GiB, 31058821120 Bytes, 60661760 Sektoren
...
root@debdev ~/Downloads # unxz 2024-03-15-raspios-bookworm-armhf-lite.img.xz 
root@debdev ~/Downloads # dd if=2024-03-15-raspios-bookworm-armhf-lite.img of=/dev/sdc bs=4M

When flashing is finshed. Mount the boot partition

root@debdev ~/Downloads # fdisk -l
....
Disk /dev/sdc: 28.93 GiB  31058821120 bytes, 60661760 sectors
Disk model: USB SD Reader
...
Device     Boot   Start     End Sectors  Size Id Type
/dev/sdc1          8192 1056767 1048576  512M  c W95 FAT32 (LBA)
...
root@debdev ~/Downloads # mkdir /mnt/sdc1
root@debdev ~/Downloads # mount /dev/sdc1 /mnt/sdc1
root@debdev ~/Downloads # cd /mnt/sdc1
root@debdev /mnt/sdc1 # export NEW_USER=pi
root@debdev /mnt/sdc1 # echo "$NEW_USER:$(echo 'myNewPassword' | openssl passwd -5 -stdin)" >  userconf

And start sshd at boot

root@debdev /mnt/sdc1 # touch ssh

Also possible…

root@debdev /mnt/sdc1 #  echo "$NEW_USER:$(echo 'myNewPassword' |  mkpasswd --method=SHA-512 --stdin)" >  userconf

Unmount the sd card

root@debdev /mnt/sdc1 # cd ~
root@debdev ~ # umount /mnt/sdc1
root@debdev ~ # sync

Insert the sd card into the raspberry and enjoy 🙂

Michael

Leave a Reply