Sorry, try again. after [sudo] password for ..., ending in
sudo: 3 incorrect password attempts, means sudo did not accept the password you typed.
In WSL there is no default password to look up: sudo wants your own Linux user's password, the one
you chose when the distribution first started. If you have forgotten it, reset it from Windows as
root, which asks for no password at all.
In PowerShell run wsl -d Ubuntu-24.04 -u root passwd fix3user, type a new password
twice, and use it with sudo. Replace Ubuntu-24.04 with your distribution's name and
fix3user, the throwaway user made for this test, with your own Linux user name.
The error
$ printf 'guess-one\nguess-two\nguess-three\n' | sudo -S true
[sudo] password for fix3user: Sorry, try again.
[sudo] password for fix3user: Sorry, try again.
[sudo] password for fix3user: sudo: 3 incorrect password attempts
The guesses were fed on standard input with sudo -S, so each reply runs on from the
prompt. Typed into a terminal, Sorry, try again. sits on its own line under the prompt;
the words are the same.
Why it happens
Ubuntu's sudoers file lets members of the sudo group run anything
(%sudo ALL=(ALL:ALL) ALL), but only after they type their own password. Your WSL user
was created at first launch with the password you entered then, and on Ubuntu that user is in the
sudo group (the one on this machine was). Nothing
in WSL keeps a copy of it or has a default. The root account is no help from inside either:
passwd -S root reports L, locked, meaning root has no password anyone
could type.
The way in is wsl.exe itself. The Windows user who owns the distribution can start any
command in it as any Linux user with -u, root included, and no password is asked;
wsl -d Ubuntu-24.04 -u root whoami simply printed root. As root,
passwd sets another user's password without asking for the old one.
The fix
PS> wsl -d Ubuntu-24.04 -u root whoami
root
PS> wsl -d Ubuntu-24.04 -u root passwd fix3user
New password: Retype new password: passwd: password updated successfully
Here the two prompts were answered from a file rather than typed, which is why they share a line; at a keyboard you type the new password twice and nothing appears on screen. Then, back as the user, sudo accepted the new password:
$ sudo -S whoami < /tmp/fix3-owsl/c5/pw/fix3user.txt
[sudo] password for fix3user: root
Microsoft's WSL setup guide gives the same steps for a forgotten password: open the distribution as
root with wsl -u root, run passwd with the user name, then
exit. Leave out -d Ubuntu-24.04 to use your default distribution.
How it was reproduced
Ubuntu 24.04.4 under WSL2 with sudo 1.9.15p5. A throwaway user, fix3user, was created as
root with useradd -m -s /bin/bash -G sudo and a random password that was never shown,
so it was forgotten by design. The reset ran from PowerShell, and afterwards the user was removed
with userdel -r; its open WSL login session had to be ended first with
loginctl terminate-user, and then wsl -u fix3user answered
User not found.
Frequently asked
- What is the default sudo password in WSL?
- There is none. sudo asks for your own Linux user's password, the one you set when the distribution first started and asked for a user name and password. If you never knew it or have forgotten it, reset it from PowerShell with wsl -u root and passwd.
- What is the root password in WSL Ubuntu?
- Root has no usable password on Ubuntu: passwd -S root reports L, locked. You do not need one, because wsl -d Ubuntu-24.04 -u root opens a root shell from Windows without asking for any password.
- How do I reset a forgotten WSL password?
- In PowerShell run wsl -d <distro> -u root passwd <username>, type the new password twice, and exit. Leave out -d to use your default distribution. Only the password changes; your files and settings stay as they were.
More decoded errors in the Fixes category. If sudo asks for a password inside a script started from Windows, that is a different problem: 'sudo: a password is required'.