Skip to content

Add an option for "UNIX username" and "password" to WSL CLI #10386

@jan-revay

Description

@jan-revay

When running
wsl --install Debian

User is required to provide username and password:

Enter new UNIX username: jr
New password:
Retype new password:
passwd: password updated successfully
Installation successful!

I would like to be able to run wsl --install in a noninteractive mode (as a part of a script).

Describe the solution you'd like
Add sub-options --install-username and --install-password to wsl --install command. The expected usage would be:
wsl --install Debian --install-username jr --install-password 1234

Describe alternatives you've considered
There are some awkward ways that this can be done in PowerShell e.g. https://superuser.com/questions/1569186/unattended-wsl-ubuntu-18-04-installation-from-powershell, but I don't want to maintain 40 line script for such a simple task.

Additional context
I am installing a configuring WSL as a part of an automatic Ansible-like init script here: https://github.com/jan-revay/initPC/ (so that every time I get a new machine, I don't have to configure it manually), but as WSL is not capable of being installed in a non-interactive mode - the script stops executing during WSL install (see: https://github.com/jan-revay/initPC/blob/stable/Windows_10/wsl_install.ps1). I would like the script to be fully non-interactive, so I can start it and come to a fully configured machine in 45 minutes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions