Forgotten username and password to SSH into Pi

Hello, I have totally forgotten the username and password for the Pi itself rather than the Octoprint user....So I'm able to use Octoprint, just not SSH into it to make some needed changes. Is there a way I can reset it rather than a full reinstall?

I tried opening the file 'cmdline.txt' and add 'init=/bin/sh' to the end. But it did not boot to single user mode to sign in as su and reset the password with 'passwd pi', it was just showing as inactive connection on PuTTY.

For a standard installation, the username is pi and the the password is raspberry.
If you had chanced it, you even could not use restricted commands (like sudo) when you plug in a monitor and a mouse to the Pi.

My suggestion: Make a backup of the stored OctoPrint settings and data and play them back to a new OctoPi/OctoPrint installation.

1 Like

Sounds like the way to go!

Thank you.

Or load the micro-SD card into a computer (PC, Mac) and edit the password file?

First make a full mackup on the computer before you edit the password file, if you're unsure about this. If you do the editing on a PC, beware of the Windows - Linux end of line difference, e.g.

The password file (/etc/passwd) is located in the root directory, not the boot directory.
Windows PC can't read Linux formats...
In the end, he just has to read the user/password data, and the password is encrypted.
But as I said, not on a Windows PC.

And I'll add to this ^ that macOS also can't mount/read that second ext4 partition.

If you can get your hands on an Ubuntu Live CD or USB you can boot up your workstation so that you can edit files on that second partition.

But that suggestion to use Notepad for this since is a moot point. Use nano (command line) or gedit (GUI).

1 Like

Take the SD card out, put it in a card reader. Create a file octopi-password.txt on it, containing a new password as it's only line. Unmount, boot, login with the new password.

Put that in ages ago for cases liked this and for easier provisioning. Should hopefully still work.


This still works! Such a great idea, there was no way i was going to remember the password, and the init=/bin/sh method didn't work for me so this was perfect. Great foresight!

1 Like