Change a Raspberry Pi User Password
Learn how to change a Raspberry Pi OS password with raspi-config or passwd, verify the change, and avoid common login and lockout problems.
Why change your Raspberry Pi password?
A password is a secret used to authenticate a user account. Predictable credentials create a security risk, particularly when a Raspberry Pi is connected to a home, office, or public network.
The primary Raspberry Pi OS account commonly has sudo privileges. Sudo allows an authorized user to run administrative commands. An attacker who obtains that account's password may therefore be able to make system-level changes. The root account is the unrestricted superuser account; you normally use sudo rather than signing in directly as root.
Choose a unique, sufficiently long, memorable passphrase or password. Do not reuse it on other services, and store it in a secure password manager or another protected location.
Understand the Raspberry Pi account name
Raspberry Pi OS is the Linux operating system commonly used on Raspberry Pi devices. Older releases were called Raspbian. Historically, many installations used the account name pi with the initial password raspberry. Those predictable credentials should never be left unchanged on a networked device.
Current Raspberry Pi OS installations commonly ask you to create a username and password during first-run setup. As a result, the pi account may not exist. Substitute your actual username whenever an instruction refers to pi.
Identify the current username
Open a terminal and run:
whoamiThe command prints the username of the currently signed-in account. This is useful when your installation does not use the historical pi account.
Method 1: Change the password with raspi-config
raspi-config is Raspberry Pi OS's interactive, text-based system configuration utility. Start it from a terminal with:
sudo raspi-config- Use the arrow keys and Enter to select the option for changing the current user's password. The wording and menu position can differ between Raspberry Pi OS releases.
- Read the prompt, then enter the new password.
- Enter the same password again when asked to confirm it.
- When the change completes, choose the option to finish or exit raspi-config. If the utility asks whether to reboot, reboot only if needed for another configuration change; a password change itself applies immediately.
Password input is intentionally hidden. No letters, dots, or asterisks appear while you type. Enter the password carefully and press Enter.
Method 2: Change the password with passwd
passwd is the Linux command for changing account passwords. To change the password for the account currently signed in, run:
passwdThe command may ask for the current password first. It then asks for the replacement password twice to catch typing errors. You do not normally need sudo to change your own password.
An authorized administrator can change a named account's password with:
sudo passwd <username>For example, on an older system where the historical pi account actually exists:
sudo passwd piReplace <username> with the target local account name. When an authorized administrator resets another user's password, the target user does not need to know the old password. The administrator should communicate the replacement securely and follow any local policy about changing it again at the next appropriate login.
Password selection and safe handling
- Use a long passphrase or password that is difficult to guess and not reused elsewhere.
- Record it securely before ending your existing administrative session.
- Do not put passwords in shell history, scripts, screenshots, or unprotected notes stored on the Pi.
- Many terminal prompts show no visible characters at all while a password is entered. This is normal and does not mean the keyboard is not working.
Verify the new password
A successful password change takes effect immediately. Keep your current session open and verify the new password in a separate local terminal, console, SSH session, or by logging out and back in.
SSH is a secure remote-login protocol often used to administer a Raspberry Pi without a monitor. For a remote change, change the password in the active SSH session, leave that session open, and open a second SSH connection. Authenticate with the new password before closing the first session.
Saved SSH client credentials, deployment tools, scheduled jobs, or scripts that intentionally use password authentication may still contain the old password. Update those credentials where necessary. For remote administration, SSH keys are generally preferable to storing passwords in scripts.
Practical examples
Older installation using pi
- Sign in as
pi. - Run
sudo raspi-configand choose the password option, or runpasswdto change the signed-in account. - Enter and confirm a unique replacement password.
- Test it in a second local terminal or SSH session before closing the existing session.
Modern installation with a custom username
- Run
whoamito identify the current account. - Run
passwdto update that account, or ask an administrator to runsudo passwd <username>. - Do not use
sudo passwd piunless the historicalpiaccount exists.
Administrator changing another account's password
- Use an account authorized to run sudo.
- Run
sudo passwd <username>with the correct target username. - Provide the replacement password twice when prompted.
- Tell the account owner the new password through a secure channel and follow any policy requiring a subsequent change.
Troubleshooting
Nothing appears while typing
Terminal password prompts suppress visible input. Type carefully and press Enter. The absence of characters, including asterisks, is expected.
The confirmation does not match
The two entries differ, possibly because of a typing error, Caps Lock, a modifier key, or a different keyboard layout. Repeat the operation, check Caps Lock, and verify the expected keyboard layout.
sudo passwd pi says the user does not exist
The installation may use a custom username, or the historical pi account may have been removed. Run whoami for the current account, or use the correct target name with sudo passwd.
The new password is rejected during login
Check that you are using the correct username. Also check the keyboard layout and Caps Lock at the login screen. If you may have forgotten the password, use an existing authorized administrator account or an authorized local recovery procedure.
Permission is denied when changing another user's password
The signed-in account lacks the authorization required for that operation. Use an account permitted to run sudo, or ask the system administrator to perform the reset.
Remote services or scripts stop authenticating
They may still be using the previous password. Update stored credentials where password authentication is intentionally used, and consider SSH key-based authentication for remote administration.
Avoid being locked out
Before ending the session that currently has administrative access, securely record the new password and verify it through another login path. A forgotten password is different from a password rejected because of keyboard layout, Caps Lock, or an incorrect username. If access is lost, use another authorized administrator account or the approved local recovery procedure for the device. Do not attempt to bypass access controls on a system you are not authorized to administer.
Related Raspberry Pi topics
For more terminal practice, see Terminal In Raspbian and Useful Terminal Commands. For remote administration, read Enable SSH In Raspbian and Access Raspbian Remotely. To understand the wider configuration utility, see Raspi Config.