2022-05-09

Resetting debian account password

linux

I needed to run a sudo command recently on my Debian Linux box. Unfortunately, I had forgotten the password on the main account since I was using an ssh key for all my needs. I also locked root and couldn't access via ssh.

Since I have physical access, I thought this would pretty easy. Everyone always says that with physical access, it's trivial to get root access.

At first, I tried simply booting into recovery mode. Sadly, I was greeted with a message that my root account was locked and the defaults didn't work.

So, I followed the instructions here. For my own reference, it basically consisted of modifying the advanced boot options on boot. The specific modification was to change the line that looks like linux /vmlinux... root=... other stuff to something like linux /vmlinux... root=... init=/bin/bash and then starting the boot process. In theory after that occurs, I can simply remount using mount -o remount,rw / followed by resetting the password via passwd myUser.

Unfortunately for me, that didn't work either. The error message that greeted me was:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device

I found someone who encountered a similar problem on askubuntu, but sadly there was no solution. Like the person on askubuntu, I had that message and pressing keys on the keyboard had no response. I had to physically press the reboot button to get back to GRUB.

However, I noticed one thing. The logging indicated that my USB keyboard was being detected. But the timestamp was after the ioctl related message. Since I had no better ideas, I swapped the keyboard's USB port to a different one. Miraculously, that USB port was loaded before the ioctl error. Because of that, even though I still got the ioctl error message, pressing keys on my keyboard worked! With that, I was able to do the mount/passwd commands and reset my password. Interesting that the specific port chosen actually mattered!


Any error corrections or comments can be made by sending me a pull request.

Back