Password Lockout on 3.5.0

I wonder if I use the file manager within side-dress. It might let me click on properties to change the read attributes, possibly. Or maybe a simple will copy paste who knows but at least we got this far. We’ll stay in touch

Sorry, I misinterpreted what you said when you said you “just built a Raspian Pi” - I thought you meant that was the system you wanted to recover.

It’s owned by root, you’ll need to sudo if running on a system that understands ext4 permissions (like Linux)

Yes, in Raspbian Jessie running on RPi, I used sudo, but still it does not save, saying it is write only.
I tried in Ubuntu 16.04 Desktop, and the file properties/permissions say read only.

I tried again in Ubuntu 16.04 on my Desktop, and this time instead of file manager, used console as root. i did succeed in editing and saving file “/media/usb/etc/shadow”.
pi::17422:0:99999:7:::

I slipped the microSD card in Pi and booted. When I wanted to ssh, it asked for password. I tried blank password and password flightaware (I have not changed default password), but failed to ssh.

I then shutdown pi, sliped out card and plugged into Desktop/Ubuntu and added a star after pi: as shown below, and tried again. No success, pi asks for password, and does not accept a blank password or original password. Can not ssh. :angry:
pi:*:17422:0:99999:7:::

Good thing is that I made this experiment on a spare microSD card, so finally I took it out and slipped in the original healthy microSD card in Pi and booted, and all is well. :slight_smile:

Specifically for logging in via ssh, you’d need to also have PermitEmptyPasswords yes configured in /etc/ssh/sshd_config

Alternatively you can generate a hash for the password you want, but at this point we’re getting well out of “how do I recover the system” and into general “how do I administer a system” which is a huge topic I really don’t want to get in to…

Thanks for the tip. I will give it a try tonight.

By the way, during this experiment I also learned how to recover a messed up password in Ubuntu. I had by mistake deleted password entry in shadow of Ubuntu , was very sleepy as it was late night. Morning when I wanted to boot into Ubuntu, it refused to accept my password. I then realized that in night I have messedup with Ubuntu’s password while trying to fix Pi’s pasdword.

I had to spend 3 hours, Googling and trying, and finally could restore Ubuntu’s password and login. It was a good learning experience, a blessing in disguise. :smile:

Another option is to just restore the original /etc/shadow line used in the unmodified sdcard image, which will restore the original default password:

pi:$6$ZEOUoA/D$PRg33x2kTQR4QtC1uM/9Fi9tb9ASzT62iPnHmBoJUU3eH5oazH56W5wYS44V4TEb.bCBI61ssQHnkeUJDAHJu1:17422:0:99999:7:::

Thanks.
Right now recovering from shock of Ubuntu unexpectedly getting into coma, and then comming out of coma. :smile: Will try both tonight:

PermitEmptyPasswords yes
and pi:$6$ZEOUoA/D$PRg33x2kTQR4QtC1uM/9Fi9tb9ASzT62iPnHmBoJUU3eH5oazH56W5wYS44V4TEb.bCBI61ssQHnkeUJDAHJu1:17422:0:99999:7:::

1 Like

@obj

SUCCESS!! :smile: when replaced Pi’s encrypted password by default password “flightaware” in encrypted form

(1) Determined which partition is Piaware

abcd@abcd-PC:~$ sudo fdisk -l
.............
.............
 Device     Boot      Start        End    Sectors   Size Id Type
/dev/sda1  *          2048     718847     716800   350M  7 HPFS/NTFS/exFAT
/dev/sda2           718848  420558847  419840000 200.2G  7 HPFS/NTFS/exFAT
/dev/sda3        420558848 3574478847 3153920000   1.5T  7 HPFS/NTFS/exFAT
/dev/sda4       3574480894 3907024895  332544002 158.6G  5 Extended
/dev/sda5       3574480896 3898640383  324159488 154.6G 83 Linux
/dev/sda6       3898642432 3907024895    8382464     4G 82 Linux swap / Solaris
..............
..............
Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1          8192 1056767 1048576  512M  b W95 FAT32
/dev/sdb2       1056768 6791167 5734400  2.8G 83 Linux

.
(2) Mounted Piaware Partition

abcd@abcd-PC:~$ sudo mkdir /media/usb
abcd@abcd-PC:~$ sudo mount -t ext4 /dev/sdb2 /media/usb
abcd@abcd-PC:~$ ls /media/usb
bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
boot  etc  lib   media       opt  root  sbin  sys  usr

.
(3) Edited file /etc/shadow and replaced line pi:xxxxxxxxxxxxxxxxxxxxxxx by encrypted version of pasword “flightaware”

abcd@abcd-PC:~$ sudo nano /media/usb/etc/shadow

#replaced line starting with pi: by following line.
pi:$6$ZEOUoA/D$PRg33x2kTQR4QtC1uM/9Fi9tb9ASzT62iPnHmBoJUU3eH5oazH56W5wYS44V4TEb.bCBI61ssQHnkeUJDAHJu1:17422:0:99999:7:::

 #Saved file, closed editor.
#unmounted microSD card 
abcd@abcd-PC:~$ sudo umount /media/usb/sdb2
abcd@abcd-PC:~$ sudo umount /media/usb/sdb1

.
Slipped the microSD card in RPi, powered up, ssh, entered flightaware when asked for password, and ssh successfully started. :smile:
.

(2) No Success when tried following:

sudo nano /etc/ssh/sshd_config
#changed no to yes in following line:
PermitEmptyPasswords  yes
#Saved file, re-boot

Wow! Amazing!
I will have to try this later on today.
I will stay in touch and let you know my results.
:slight_smile:

Piaware / Raspbian running on RPi do NOT let pi user to edit the file /etc/shadow, saying file is read only and only owner root has permission to write. I added root and root password by command sudo passwd root, then switched to root by command su, but even as root, Piaware / Raspbian did NOT allow editing of file shadow.

The success in my last post was achieved by plugging the USB card reader into my PC running Ubuntu 16.04 arm64, and NOT on RPi running Piaware.

There’s nothing magic about /etc/shadow; it’s a file like any other file. If you can’t write to it, check the permissions.

permissions are -rw -r -r owner root
I tried to change permissions
sudo chmod 777 /etc/shadow, but the permission did not change
I then tried by adding password for root
sudo passwd root
added password twice
su
root@piaware:#
tried again to edit, failed, then tried to change file permissions, failed :frowning:

stat -c "%a %n" /etc/shadow
640 /etc/shadow

ls -l  /etc/shadow
-rw-r----- 1 root shadow 1381 Oct 12 12:51 /etc/shadow

As very few of us have a Linux running on PC, for password recovery, the most covenient solution is to use Linux on RPi.

Unfortunately the most popular Linux on RPi i.e. Raspbian does not let file /etc/shadow of external microSD card to be edited (may be it allows to edit /etc/shadow on its own microSD card).

I have now tried another method. I downloaded Ubuntu Mate Xenial for RPi 2 / RPi 3, wrote it to spare microSD card, booted RPi from Ubuntu Xenial. Next plugged in the locked-out microSD card into RPi’s USB port using a card reader. With this method, I succeeded in fixing the locked out password.

Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.38-v7+ armv7l)
.......
Last login: Thu Oct 12 10:42:20 2017 from 192.168.0.10
abcd@ubuntu:~$ sudo fdisk -l
[sudo] password for abcd: 
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
............
Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
............
Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
...............
Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
..............
Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
..............
Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
..............
Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
..............
Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
............
Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
.............
Disk /dev/mmcblk0: 7.3 GiB, 7860125696 bytes, 15351808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1d8c09f0

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        2048   131071   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 15351807 15220736  7.3G 83 Linux

Disk /dev/sda: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc95dc9ba

Device     Boot   Start     End Sectors  Size Id Type
/dev/sda1          8192 1056767 1048576  512M  b W95 FAT32
/dev/sda2       1056768 6791167 5734400  2.8G 83 Linux

By fdisk command above,came to know that /dev/sda1 is Piaware’s boot partition and /dev/sda2 is Piaware’s file partition.

Now mounted the under-repair microSD card to access its files

abcd@ubuntu:~$ sudo mkdir /media/usb
abcd@ubuntu:~$ sudo mount -t ext4 /dev/sda2 /media/usb

abcd@ubuntu:~$ ls /media/usb
bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
boot  etc  lib   media       opt  root  sbin  sys  usr

abcd@ubuntu:~$ sudo nano /media/usb/etc/shadow
#edited file shadow. 
#replaced line starting with pi: by following line.
pi:$6$ZEOUoA/D$PRg33x2kTQR4QtC1uM/9Fi9tb9ASzT62iPnHmBoJUU3eH5oazH56W5wYS44V4TEb.bCBI61ssQHnkeUJDAHJu1:17422:0:99999:7:::

#saved file, closed editor.

#un-mounted microSD card 
abcd@ubuntu:~$ sudo umount /media/usb
[sudo] password for abcd: 
abcd@ubuntu:~$ ls /media/usb
abcd@ubuntu:~$
#un-mounting successful, no files now in /media/usb

Removed microSD card under repair from card reader, slipped in RPi, booted, and successfully ssh and logged in using password flightaware

Make sure you are mounting correct partition, else you may edit files in wrong drive/partition.

The partition number of Piaware microSD card will depend on your computer, and most likely will be different from the ones I have used in my posts. The Piaware partition can be any one of sda, sdb, sdc, sdd, etc. Please do NOT blindly use partition numbers I have used. Ascertain it from disk size and other details in the output of sudo fdisk -l command.

Linux/Mac OS partition numbers are very similar, and one can easily make a mistake. The Windows partition numbering C, D, E, etc is less prone to accidentally using wrong drive/partition.

Yesterday, when I was trying to fix locked microSD card using my PC with Ubuntu, I selected partition of ubuntu and edited it’s file shadow, thinking I am editing microSD card’s shadow file. I did not feel anything wrong at that time, and after about an hour, finished my work and shutdown PC. Next morning when I started PC, it was lockedout and wont accept any password. I then realized that last night I have used wrong partition and messedup Ubuntu on PC.

It took me lot of Googling and trying, and took me 3 hours to restore it. So be careful about using right one. Partition names sda, sdb, sdc, sdd etc. are very similar and very easy to messup.

There’s nothing in Raspbian that prevents this; you’re doing something wrong. (I don’t know what exactly, because I don’t see this on my systems at all)

You are right. It is possible that I am doing something wrong, as I have done all these excercises during late night, when I am tired and sleepy.

Tonight or tomorrow I will again try on Raspbian Jessie (Piaware sd card) and Raspbian Stretch. This time I will do it slowly and carefully to avoid any mistakes. Will post outcome.

There’s the bit of information that you omitted - you’re using a piaware sdcard image. The piaware sdcard image automounts USB mass storage devices (e.g. sdcard readers) read only to look for config data. Either you need to remount it readwrite or use a standard image, not a piaware image (the piaware image really is not intended for general-purpose use, it’s specifically about running piaware)

Fixing Locked-out card using RPi Running Piaware SD card img

Thanks Oliver. Remounting microSD card as read-write worked, and I could fix the locked-out card using RPi running Piaware SD card img. :smile:
.

(1) Slipped locked-out microSD card in a Card Reader, and plugged the Card Reader into USB Port of RPi.
,

(2) Checked if Locked-out microSD card’s partitions are auto-mounted. Found yes auto-mounted.

pi@piaware:~$ ls /media
usb
pi@piaware:~$ ls /media/usb
sda1  sda2
pi@piaware:~$ ls /media/usb/sda2
bin   dev  home  lost+found  mnt  proc  run   srv  tmp  var
boot  etc  lib   media       opt  root  sbin  sys  usr

.
.
(3) Remounted locked-out mixroSD card partitions as read-write.

pi@piaware:~$ sudo mount -o remount,rw /media/usb/sda2
pi@piaware:~$ sudo mount -o remount,rw /media/usb/sda1

.
(4) After remount read-write, could edit and save file /media/usb/sda2/etc/shadow

pi@piaware:~$ sudo nano /media/usb/sda2/etc/shadow
#edited file shadow. 
#replaced line starting with pi: by following line.
pi:$6$ZEOUoA/D$PRg33x2kTQR4QtC1uM/9Fi9tb9ASzT62iPnHmBoJUU3eH5oazH56W5wYS44V4TEb.bCBI61ssQHnkeUJDAHJu1:17422:0:99999:7:::

#saved file, closed editor.

.
.
(5) Un-mounted microSD card

#un-mounted microSD card 
pi@piaware:~$ sudo umount /media/usb/sda2
pi@piaware:~$ sudo umount /media/usb/sda1

#checked un-mounting succeeded:
pi@piaware:~$ ls /media/usb/sda2
pi@piaware:~$ ls /media/usb/sda1
#un-mounting successful, no files now in /media/usb

(6) Removed locked-out microSD card from card reader, slipped into RPi, booted, and successfully ssh and logged in using password flightaware