Until recently, all Raspberry Pi OS systems were installed with the same user and password (pi / raspberry). This is very convenient when you install it, but it can lead to security issues. Also, you may want to change your password regularly for security reasons. Here is how to do this.
On Raspberry Pi OS with Desktop, the password can be changed via the Raspberry Pi configuration tool, under Preferences in the main menu. On Raspberry Pi OS Lite or SSH, use the command “passwd”.
For more information, keep reading. I’ll explain the step-by-step process to change your password in each case. I’ll also provide a guide on what to do if you have lost your password.
If you need help getting started on Raspberry Pi, I have an entire course to guide you through your first steps. I’ll help you use the perfect hardware, plug everything in and install your first system. You’ll also do your first project with me, just to make sure you are ready for the next level. Get all the information on this page if you are interested.
Set the new password on Raspberry Pi OS
From 2012 to 2022, all Raspberry Pi models were pre-installed with the same username and password: pi / raspberry. Since April 2022, using a different username and password is now required on the first boot.
Welcome wizard on first boot
If you are using the latest Raspberry Pi OS version, you’ll get that kind of assistant showing up on your first boot:
After setting up your local settings, essentially your keyboard layout, you’ll get a new screen where you can create the first user:
You’ll get something similar when you first start on Raspberry Pi OS Lite (without a desktop environment).
So basically, you can no longer avoid setting up a new username and password when you install Raspberry Pi OS. But if you want to change it later, or are using an older version of Raspberry Pi OS, I’ll explain how to change your password in the next parts.
Using Raspberry Pi imager
Another option if you want to skip this welcome assistant, is to use Raspberry Pi Imager, and especially the advanced settings, to set the new user and password directly on the SD card when you flash the new operating system.
To achieve this, click the wheel icon in the bottom-right corner of this tool once the system version chosen.
Then fill the form with at least the username, password and locale settings.
After using this, you should skip the first boot wizard, and get access directly to your desktop environment. This is particularly useful if you are installing new systems all the time, but let’s get back to your original question.
Note that even if you lose this password, there are a few ways to reset a forgotten password on a Raspberry Pi. Click on the link to learn more about this.
Change password on Raspberry Pi OS with Desktop
If you are on Raspberry Pi OS with Desktop, it should be pretty easy to change the password. I have included screenshots with the step-by-step guide below to help you with this procedure.
By the way, you absolutely need access to a session on Raspberry Pi OS to do this. If you have lost your password, check the last part of this tutorial before getting started below.
Before going further, I want to remind you that the welcome wizard on Raspberry Pi OS is a pretty neat tool that allows you to change many things, including the password for the “pi” user.
That’s almost the first question it will ask you:
If you are just installing your system, this is the easiest way to change your password. Follow this wizard, set a password, and configure the basic settings.
Raspberry Pi Configuration tool
There is a good chance you are here because you changed your password during the first boot, haven’t used your password since as the session opens without a password, and don’t remember what password you set.
No worries, you can change your password easily by following these few steps:
- Open the main menu in the top left of your screen.
- Go into Preferences and click on “Raspberry Pi configuration”.
- A window will appear with many settings you can tweak.
Click on “Change password”:
- Then you can change your password directly:
Choose a new password and enter it twice.
If you are doing this for security reasons, I highly recommend using a long password (no need for multiple special characters, but long passwords are better).
For example, I often use that kind of tool that generates long passwords that are easy to remember.
- Once done, Raspberry Pi OS will display a success message:
That’s it! You have now changed your password, and can proceed with whatever you were trying to do :).
By the way, if you are just getting started on Raspberry Pi, I can help you to learn much faster. My Raspberry Pi boot camp course helps you discover the Raspberry Pi device and unlock its secrets step-by-step. In a few hours, you’ll be ready to start any fantastic project you are interested in.
Change password on Raspberry Pi OS Lite (or SSH)
If you just have access to a terminal, via Raspberry Pi OS Lite or remote SSH access, you can’t use the previous tools.
But don’t worry, it’s not very complicated, as there is only one command to remember (and you have the choice).
It’s not the fastest method, but it is definitely the easiest to remember.
Raspi-config is a great tool available on Raspberry Pi OS to configure most settings on your system.
It includes a function to change your password, which is what we will use in this section:
- Open a terminal, connect via SSH or log in on Raspberry Pi OS Lite.
- Start raspi-config with:
Your current password might be required to go further. If you have lost it, check the last part of this guide.
- Go to “System Options” (1).
- Then click on “Password” (S3).
- Confirm by pressing “Enter”.
- Type your new password twice.
- That’s it, you should get a confirmation message now:
- You can exit raspi-config with “Esc”.
So, Raspi-config is pretty convenient to remember, but as I told you there is still a faster solution.
The passwd command
Raspi-config is just a nice interface, running many Linux commands in the background. If you remember this easy command, you can go directly to the last step.
The command line to change a password on Raspberry Pi is:
The good news is that this solution will work on any Linux distribution, even if you are not on Raspberry Pi OS.
Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.
Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.
Recover access if you have lost your password
We have discussed how to change your password if you still have access to the user session. But can you do the same if you have lost the password?
Yes, in fact, there are several solutions.
Use another user
The easiest way is to log in with another administrator user. If you followed my guide on how to create a new user on Raspberry Pi, you can use it to reset the password of another user.
You need the sudo privileges to do this.
The command to change the user password from another session is:
sudo passwd <user>
So, for example:
sudo passwd pi
If you are logged in with another user, you can change it directly and recover access to this session.
Another option could be to change the default username on your Raspberry Pi.
Log in with root
A similar way is to use the root user directly.
If you have allowed it to access SSH, you can follow the same steps as with another user (you just don’t need sudo).
What you can also do, is removing the password requirement on another session. Here is the command to do this:
sudo passwd <user> -d
Once done, you can open a session with this user without any password, and change it following the first part of this tutorial.
Unfortunately, there is no other way. As the root user is not enabled by default, you can start in single user mode or anything like that, which I use on Linux from time to time.
Whenever you’re ready, here are other ways I can help you:
The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.
You can also find all my recommendations for tools and hardware on this page.