Forcibly change root password on Raspberry Pi

This article applies to the case where the Raspberry Pi has already installed the system, but does not know the root password, needs to change the root password, and there is no HDMI adapter:

1. Remove the Raspberry Pi SD card, install it into the card reader, then insert the card reader into a linux system computer, install this article into the kali virtual machine, and then connect the card reader to kali

2. Open the sd card in the file manager

Open shadow and shadow-file

It should look like this:

root@kali:/media/kali/f24a4949-f4b2-4cad-a780-a138695079ec/etc# cat shadow
root:$6$MeWiWkHM$ck5gW3cLZqScx/EYzswR0xNd45UaeXkyT6Aajnv85ht2b5Jia/g7wVEJX.PlhMEVm1BVC4glt/5UkbaKKv0Vr.:16945:0:99999:7:::
daemon:*:16481:0:99999:7:::
bin:*:16481:0:99999:7:::
sys:*:16481:0:99999:7:::
......

 Between the first and second colons of the root line is the encrypted password hash, change it to

$6$X8NLlS0p$8WaZ0AvJIOKnHzU.5YQqa6KGuLXsRz8zlDGL8VZKodBUQzI/SzSny7z97wxOVucrzkb1nB5MHAcckTSNpQdyA/

After the figure is modified

root@kali:/media/kali/f24a4949-f4b2-4cad-a780-a138695079ec/etc# cat shadow
root:$6$X8NLlS0p$8WaZ0AvJIOKnHzU.5YQqa6KGuLXsRz8zlDGL8VZKodBUQzI/SzSny7z97wxOVucrzkb1nB5MHAcckTSNpQdyA/:16945:0:99999:7:::
daemon:*:16481:0:99999:7:::
bin:*:16481:0:99999:7:::
sys:*:16481:0:99999:7:::
......

Both shadow and shadow- files must be modified. After the modification, install the Raspberry Pi and start it. You can log in with the root password 123456

How to generate a password:

python:

import crypt
print crypt.crypt('123456','$6$X8NLlS0p$')

123456 is the password, followed by salt

The pit that the blogger encountered: a card reader cannot connect to the virtual machine, just change the card reader

Guess you like

Origin blog.csdn.net/hailangnet/article/details/105394935