How to disable WSL password?

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 a NULL password.


Solution 1:

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.