0

I'm new to Raspbian.

I started the GUI for the first time (following a fresh install) using the instructions found here: How to set my Raspberry Pi to boot into the GUI? and the command:

sudo apt-get install lightdm

I rebooted the machine, but the default login (pi) and password (raspberry) no longer work. I don't know of any other way to reset the password.

Other than re-flashing the Raspbian image to the SD card, how can I get out of this situation?

frepie
  • 113
  • 5

1 Answers1

2

Getting a terminal makes no difference. Also there you are ask for a username and a password. But you can reset the password if you can mount the ext4 root partition on another computer. Connect the SD Card with a card reader to a linux computer and mount the root partition to e.g. /mnt. Then edit

/mnt/etc/passwd

change
pi:x:1000:1000:,,,:/home/pi:/bin/bash
to
pi::1000:1000:,,,:/home/pi:/bin/bash

/mnt/etc/shadow

change
pi:ljrp9kgwknldgp80ooutqwwe06aswrjhgdhäthtltlehihifhiljlofwerndsl/RoIJcnHQ7kAzdXi3gN.Uw6kDFNLsJqtDZk0:17761:0:99999:7:::
to
pi::::

exact 4 colons are important.

Booting this in your RasPi you should be able to login without password: username pi, password just <enter>. If you want to do it on a terminal you can try the key combination <ctrl><alt><F1> when you are on the GUI. Most GUI switch with it to a terminal.

And yes, don't forget to give a new password.

Ingo
  • 42,107
  • 20
  • 85
  • 197
  • Can you explain why my user and password are not working on the gui? – frepie Sep 15 '18 at 20:00
  • 2
    Any arbitrary password can be inserted into the /etc/shadow file if one uses the mkpasswd program to properly hash the password... mkpasswd -m sha-512 should produce a correctly hashed password. – RubberStamp Sep 15 '18 at 20:39
  • @frepie No, I don't know why user an password are not working. I don't know what you have done. Normally with a fresh fläshed Raspbian you will boot into the GUI. There is no need to set it up with raspi-config and there is no need to install another display manager lightdm like you did. – Ingo Sep 16 '18 at 11:28