How to disable WSL password?
9,449
In wsl add your username to a sudo config file.
Replace MY_USERNAME
below to your username name.
sudo nano /etc/sudoers.d/MY_USERNAME
add the following line:
MY_USERNAME ALL=(ALL) NOPASSWD:ALL
If you don't replace MY_USERNAME
with the target username you will receive an error no valid sudoers sources found
.
Author by
nowox
Software and Electronic Engineer specialized in MotionControl applications.
Updated on September 18, 2022Comments
-
nowox over 1 year
I feel there is no need for a password on WSL because it is already protected from my Windows account. Nobody could use my WSL without first knowing my Windows password.
How can I disable the WSL password? I have tried
passwd
but it does not accept aNULL
password.-
tvdo over 4 years
passwd -d
is the standard way to delete a password on Linux. Can't remember if that worked without consequences on WSL. -
BenMorel over 4 yearsFor some reason,
passwd -d
doesn't work:sudo
still asks for the password after that, and because there is none, you're locked out. Just had to reset my password by logging in as root because of this. -
JW0914 over 4 yearsThis is not recommended...
sudo
should always require a password. The password isn't there just to prevent others from logging in to your WSL environment, it's also to prevent unauthorized privilege escalation. Please use google to understand why this is never recommened for Linux, unless it's a Single User OS where the only login account isroot
-
nowox over 4 years@JW0914 Could you give me an example of some harm in WSL ? I don't think you can do privilege escalation.
-
Rich almost 3 years@nowox I think you're right and WSL2 (unless you run it as admin) can't, even as sudo, do anything a user process can't do.
-
-
xmllmx over 2 yearsIt works like a charm! Tons of thanks to you!