Raspberry Pi Default Password Guide: New Setup, Changes, and Security Tips

Raspberry Pi Default Password Guide: New Setup, Changes, and Security Tips

Oct 30, 2024

Raspberry Pi password setup interface with SSH icons and security options displayed on a connected monitor

Many users still search for the Raspberry Pi default password, but in reality, the Raspberry Pi does not have a "default" password anymore. Newer Raspberry Pi OS releases (starting with Raspberry Pi OS Bullseye, 2022) require users to create a custom password during the initial setup— see the official Raspberry Pi documentation for best practices on OS setup and security.However, for older versions of Raspberry Pi OS (before this change), the default credentials were:
Username: pi
Password: raspberry

New Setup Process (Post-2022):

For devices running Raspberry Pi OS after 2022, users define their credentials during the first boot, eliminating reliance on any default login like the old Raspberry Pi default password. This ensures better security.     

Setting Password via Raspeberry Pi Imager

1.Select the OS and SD Card, clic Next
2.Select “Edit Settings”

Raspberry Pi Imager OS customization dialog showing options to set username and password during system setup

3.Go to General Tab and check “Set Username and password”
4.Enter a username and password that we want to use as the default credentials for the Raspberry Pi—this replaces the older approach of using a Raspberry Pi default password out-of-the-box.

Raspberry Pi Imager general settings screen with options to set hostname, username, and password

Changing Password via Terminal

Option with Command ‘passwd’ 
Open a terminal and run: passwd to change Raspberry Pi password quickly and efficiently.

Terminal showing Raspberry Pi user changing password using the passwd command

Enter the current password and then change it with a new password.
Option with Command ‘raspi-config’
1.Open a terminal and run: sudo raspi-config— for a complete walkthrough of using raspi-config and configuring system options on Raspberry Pi, see this raspi-config complete tutorial.

Raspberry Pi raspi-config tool main menu with system configuration options selected

Select System Options and the option S3: Password to change Raspberry Pi password using a guided system interface.

Raspberry Pi raspi-config password menu highlighting the option to change password for the 'pi' user

Enter the current password and then change it with a new password.

Changing Password via GUI

1.Go to Menu – Preferences: Raspberry Pi Configuration
2.On System tab, clic on “Change Password” to easily update your Raspberry Pi password using the graphical interface.

Raspberry Pi Configuration GUI with the Change Password button highlighted in the System tab

Resetting Forgotten Password

If we've forgotten the password on a Raspberry Pi, we can reset it by following these steps:—especially helpful for users locked out of their Raspberry Pi default password setup.
1.Turn off the Raspberry Pi and remove the microSD card.
2.Insert the microSD card into another computer (e.g., using an SD card reader).
3.Open the SD card’s “boot” partition on the other computer. Look for the file named `cmdline.txt`.
4.Edit `cmdline.txt`:
Open `cmdline.txt` in a text editor.
Add `init=/bin/sh` at the end of the single line of text, enabling direct system access for Raspberry Pi password reset.Do not add any line breaks. The line should look something like this:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=XXXX-XXXX rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/sh
5.Save and close the file, then safely eject the microSD card and put it back in the Raspberry Pi.
6.Boot the Raspberry Pi: After it starts up, it will load directly into a root shell without needing a password— a potentially insecure state, so be sure to consult this Raspberry Pi security hardening guide for steps to properly secure your system.
7.Remount the filesystem as writable:
Type the following command to make the filesystem writable:
mount -o remount,rw /to allow changes to protected files, including those affecting Raspberry Pi login credentials.
8.Reset the password:
Use the `passwd` command to change the password for the `pi` user,completing the Raspberry Pi password recovery process.(or another username if you’re using a different one):
passwd pi
9.Revert the changes in `cmdline.txt`:
Shut down the Raspberry Pi, remove the microSD card, and put it back into the other computer.
Open `cmdline.txt` and delete the `init=/bin/sh` part you added to restore normal boot and ensure secure Raspberry Pi login.
Save the file and safely eject the microSD card.
10.Boot the Raspberry Pi normally: It should now boot with the new password.

Security Best Practices

Steps for SSH Key-Based Authentication

1.1.Generate SSH Keys on your Local Machine to enable Raspberry Pi SSH key login for higher security.
If you don’t already have an SSH key pair, generate one on your computer:
ssh-keygen -t rsa -b 4096 -C "example_your_name"
-t rsa: Specifies the type of encryption (RSA is commonly used).
-b 4096: Sets the key length to 4096 bits, which is more secure.
-C: Adds a label, like your email, for identification.
When prompted, specify a file location to save the key (default location is usually `~/.ssh/id_rsa`) and choose whether to add a passphrase for additional security— for a detailed walkthrough of SSH setup and remote access on Raspberry Pi, see this SSH with Raspberry Pi guide.

Terminal output showing RSA key pair generation process and randomart image for SSH key authentication

(Example with Windows)
2.Copy the SSH Public Key to the Raspberry Pi to enable passwordless access and improve secure Raspberry Pi access.
Once your SSH key pair is ready, copy the public key to your Raspberry Pi. Replace `pi` with your Raspberry Pi username and `your_pi_ip_address` with the Raspberry Pi’s IP address:
Linux Computer, open a Terminal
ssh-copy-id pi@your_pi_ip_address
Windows Computer, open a CommandLine
type $env:USERPROFILE\.ssh\id_rsa.pub | your_pi_ip_address "cat >> .ssh/authorized_keys"
This command will prompt you to enter the Raspberry Pi’s password (for the last time). It appends your public key to the `~/.ssh/authorized_keys` file on your Raspberry Pi, allowing passwordless login using the SSH key — also see the Raspberry Pi static IP and access guide for related remote login tips.
3.Disable Password-Based SSH Authentication
To ensure only SSH keys can be used to log in:
Open the SSH configuration file on your Raspberry Pi:
sudo nano /etc/ssh/sshd_config
Look for the line: #
PasswordAuthentication yes
Change it to:
PasswordAuthentication no to disable Raspberry Pi password login and enforce key-based authentication.

Editing the sshd_config file in Nano to disable password authentication on a Raspberry Pi

Save the file and exit, then restart SSH to apply changes:
sudo systemctl restart ssh
4.Test the SSH Key Authentication
Try logging in to your Raspberry Pi from your local machine:
ssh pi@your_pi_ip_address
If set up correctly, it will use the SSH key to authenticate without asking for a Raspberry Pi password.

In Conclusion

Managing the Raspberry Pi default password and login credentials effectively is essential to secure your device and data.By setting a custom password during the initial setup, regularly updating it, and employing SSH keys, you can protect against unauthorized access. Following these best practices helps maintain a secure environment, whether for personal projects or educational use. Implementing these security measures will ensure your Raspberry Pi remains a safe and reliable tool in your tech endeavors— for additional best practices on securing Raspberry Pi installations, see this guide to secure your Raspberry Pi.

Building a Raspberry Pi Cluster: Step-by-Step Guide and Practical Applications Back to News Comprehensive Guide to the Pin Diagram of Raspberry Pi 5: Understanding GPIO Pins and Their Functions