Ssh password lost trying to reset password fails

Using an Rpi3 ver B with the hasselfree Openhab installation on SD card.
openHAB version: 2.2

Problem:
A coupple of weeks ago I changed the default password. Everything was working fine for the next few days. Then been on a vacation, and return home just to discover I cant SSH to the system anymore, beeing rejected for wrong password. Either something is wrong, or I simply cant remeber the password.

Now I´m trying to reset the password.
First of all. I´m no good at linux. So I depend on Google and you guys.
I found this link which is rather simple at first sight…

But:

  1. My cmdline.txt does NOT look simular til the one in the example. I have no idea if it matters. But I think it does, and I have no idea how to deal with it. anyway I carried on going through the steps.
    This is my cmdline.txt:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=84fa8189-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
  1. When I reach the ‘mount -rw -o remount /’ I get an error:
    “mount: can´t find PARTUUID=84fa8189-02”
  2. I went futher anyway and entered the passwd openhabian, after that, beeing promted to enter new password and retype password.
    After that I get a new error:
    “passwd: Authentication token maipulation errro” Passwd: password unchanged".

Now I´m stuck and have no idea what to do. Can´t seem to find anyone else with simular problem.
Can anyone help?

An image from the monitor of the Rpi is supplied as well.

Greets
Kim

So, if booting the raspberry (without init=/bin/sh addition), does it boot the common way?

Yes, it boots fine normally and Openhab is running great. It´s just the password for SSH which is wrong.

I also tried change password for pi, but it respons is, “no user with pi”.
Openhabian and openhab seems to be correct usernames, but when I try to change and retype password, I get this:
“passwd: Authentication token maipulation error”
“Passwd: password unchanged”.

If it’s possible to login to the console, I would try to set the password with

sudo -u openhabian passwd

or

sudo passwd openhabian

for user openhabian.

the difference is: While the latter will ask for the old password first, the former will only ask for a new one.

I have the Rpi connected to a monitor with a keyboard as well.
Normal boot-up ends with a login promt.
I suspect it´s the same reason. I can´t log in, as it asks for my user and password, and password fails.
So I cant login to the console either.

This starts to frustrating me!

Do you have another linux machine?

e.g. you could setup a vm (download vmware player for windows and a minimal debian iso image, install vmware, select new virtual machine, select debian image as virtual cdrom, startup machine, install debian (this is almost straight forward :wink: )
If you don’t want to install vmware (or another virtualizer), you could use a live DVD (whatever, ubuntu, debian, fedora… doesn’t really matter)

After you got a GNU/Linux bash, you have to mount the openhabian sdcard, chroot to openhabian and set new passwd.

Maybe this is a bit tricky for a non GNU/Linux user… but it’s not really hard work. You have to get information, which device is the correct one. For this, connect the sdcard after login to the new bash. after a few seconds, type (without ### part)

dmesg  ###get last messages from kernel

and find the last devices /dev/sd… (something like sdc2, sdc3, sdd2 or so, depends on your builtin hardware, how many harddisks and so on)
Then mount this device:

su  ###become super user
mount /dev/sdc2 /mnt  ###mount device to folder /mnt

take a look at the filesystem:

ls /mnt/ ###list contents of /mnt

there should be at least etc/ bin/ sbin/ usr/ home/ root/ and some more. If not, this is the wrong device, so unmount it by typing unmount /mnt and try another /dev/sdc…
if you found the right one, use

chroot /mnt/ ###act as if /mnt was /

to “login” as root into openhabian.
then use

passwd openhabian 

to set a new passwd.

Thx alot Udo_Hartmann.
Will give it a try. Seems rather simple. I got a spare laptop with cardreader… It should do the trick… Just need a Debian image or something simular which runs from a USB flash, as the laptop does not have a DVD drive.

Get the iso:

https://www.debian.org/distrib/netinst.en.html#smallcd

create a usb stick:

https://www.debian.org/releases/stable/amd64/ch04s03.html.en#usb-copy-isohybrid

Hmm…
Got a new debian up running. Inserted the SDCard, and after the dmegs I do se the SD Card allrigth, but I cant seemt to mount it… It´s no reconized as a scd2 or sdc3…

I only have the USB stick and the SD card connected.

If I try to mount the mmcblk0 I get an error:

mount: “wrong fs type, bad option, bad superblock on dev/mmcblk0, missing codepage or helper program, or other error”

Got a little futher now… Found out what partion to mount. It was mmcblk0p2 :slight_smile:
Found it by running a fdisk -l

Now I have problems with chroot. When I try:
chroot /mnt/

I get an error…
"chroot: fail to run command ‘/bin/bash’: Exec format error
:frowning:

Have been googling or night now… My latest problem seems to be the architecture.
As the SD card is from Openhab on a Rpi, and my Debian on my laptop is a i686, I suspect this is the problem, even though both are running 32bit??

Well, how to fix that? Would I need this: qemu-user-static ?

Argh… totally forgot about this.

But as you now have a debian envionment, maybe it would suffice to manually delete the password:

  1. sudo mount mmcblk0p2 /mnt
  2. sudo cp /mnt/etc/shadow /mnt/etc/shadow.old (if something went wrong, this is the backup)
  3. sudo nano /mnt/etc/shadow
  4. find the line for openhabian user and delete everything between first and second :
    for instance, if the line looks like
    openhabian:$1$8NFmV6tr$rT.INHxDBWn1VvU5gjGzi/:12209:0:99999:7:-1:-1:1074970543

it then should look like

    openhabian::12209:0:99999:7:-1:-1:1074970543
  1. save the file by typing <ctrl>-x (and confirm with y )
  2. sudo umount /mnt

After that the user should have no password at all and you should be able to login as user openhabian without being asked for a password (not via ssh!).

  1. enter a new password by typing passwd when user openhabian is logged in.
1 Like

Thx Udo…
Will give it a try tonight when I get home… Whenever this is fixed, I end up beeing a Linux guru :smile:

That’s the spirit :wink:

Did as descriped, but still beeing rejected when ssh using Putty without a password.
Do I have to log on locally first and set a new password?

You can’t login with ssh when the passphrase is empty

the last three words…
You have to login locally and enter e new password (by typing passwd)

1 Like

Yeah, I thought that was you meant after I wrote it :slight_smile:

Just logged in locally, and bingo!.. I could log in without a password… and have set a new password as well.
And now I can ssh again… :smiley:

Thank you very much Udo… I owe you big time!! It has been a huge experience for me…

I had a similar issue changing passwords on the raspberry pi at first I though I typed in the wrong password or wrote it down wrong. but the issue had to do with my wireless keyboard. the # key on the console returns a £ symbol instead this is different from what my ssh putty client inputs. Of course when you set the password all of your characters are not displayed on the screen so you wont recognize the difference. I only noticed later when working on another build on the raspberry pi.
A search of the internet brings up several issues about this problem.

Another solution is to add your ssh public key to the authorized keys of openhabian.

You have to have, or either generate a keypair (Linux/Mac: What is ssh-keygen & How to Use It to Generate a New SSH Key?, Putty: How to install and use puttygen to create new key pairs and change passphrases. Installing keys on server, managing SSH keys.).

Mount the SD-card and your public key to [mount-path]/home/openhabian/.ssh/authorized_keys.
(Mac: How to mount Raspberry Pi SD card using Mac | by Iván A | Medium)