Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy WSL with a regular user #90

Open
kousu opened this issue Mar 21, 2021 · 0 comments · May be fixed by #91
Open

Deploy WSL with a regular user #90

kousu opened this issue Mar 21, 2021 · 0 comments · May be fixed by #91

Comments

@kousu
Copy link

kousu commented Mar 21, 2021

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".

@kousu kousu linked a pull request Mar 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant