Skip to content

Deploy WSL with a regular user #90

@kousu

Description

@kousu

It would be nice if, instead of

https://github.com/microsoft/windows-dev-box-setup-scripts/blob/d488050/README.md#how-to-run-the-scripts

If you are using WSL there's a followup step we recommend after running the setup script. When the script finishes you will only have a root user with a blank password. You should manually create a non-root user via $ sudo adduser [USERNAME] sudo with a non-blank password. Use this user going forward. For more info on WSL please refer to the documentation.

there was a way to auto-install with a regular user. I've opened an issue about this 'upstream': microsoft/WSL-DistroLauncher#90, but there's a workaround that maybe you could apply temporarily: microsoft/WSL#3369 (comment):

$username = "ubuntu"
$password = "ubuntu"

ubuntu1804 install --root

wsl -u root useradd -m "$username"
wsl -u root sh -c "echo "${username}:${password}`n" | chpasswd" # wrapped in sh -c to get the pipe to work
wsl -u root  chsh -s /bin/bash "$username"
wsl -u root usermod -aG adm,cdrom,sudo,dip,plugdev "$username"

$uid = (wsl -u root id -u $username)

$distro = (Get-ItemProperty -Path Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss -Name DefaultDistribution).DefaultDistribution
$cur_id = (Get-ItemProperty -Path Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\$distro -Name DefaultUid).DefaultUid
Set-ItemProperty -Path Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\$distro -Name DefaultUid -Value $uid

With this, you can just say

If you are using WSL take note that the login is "ubuntu:ubuntu".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions