- How to reset kali linux password in windows subsystem for linux
- 3 Answers 3
- Further details:
- Сброс пароля для WSL Linux Distro в Windows 10
- Чтобы сбросить пароль для WSL Linux Distro в Windows 10,
- Forgot Linux Password on WSL? Here’s How to Reset it Easily
- Reset forgotten password for Ubuntu or any other Linux distribution on WSL
- Step 2: Reset the password for the account
- Step 3: Set regular user as default again
- If resetting WSL password is this easy, is this not a security risk?
- Were you able to reset WSL password?
How to reset kali linux password in windows subsystem for linux
I have installed Kali Linux subsystem on windows. And now I have forgotten the root password in Kali, there is just the terminal of Kali Linux and nothing else. How can I reset my password safely? Note: I have installed both Ubuntu and Kali Linux installed at the same time But when I run bash by default it opens up ubuntu
Open the HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss registry. Find the registry value DistributionName==Kali_Linux . Change defaultUID registry to zero. Open Kali, type passwd change root password.
3 Answers 3
I have installed both Ubuntu and Kali Linux installed at the same time But when I run bash by default it opens up Ubuntu.
In new Windows versions, users can install and run multiple GNU/Linux distributions. One can configure the default distribution (i.e. the distribution that comes up with wsl.exe ) with wslconfig /s command. e.g. To open Kali with wsl.exe at first run, use this command wslconfig /s kali-linux or run kali.exe .
I have forgotten the root password in Kali, there is just the terminal of Kali Linux and nothing else. How can I reset my password safely?
First of all, I don’t know if this procedure is safe or not. At the time of writing, WSL manages the default login user from DefaultUID registry (this may change in future). Close any opened WSL instance. To edit this registry value, open Registry Editor or regedit.exe from start menu or run dialog box. Go to this registry path or type this path with Ctrl + L in that Window:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss
You may see one or multiple subkeys (like subfolders) with names something like (called GUID). Double click on them to open one-by-one and match the DistributionName value with your desired distribution name, here it will be kali-linux (see below). Double click on the DefaultUID value and change it to ZERO. Zero is for root user and 1000 or 0x3e8 (in hexadecimal) for normal users.
Open wsl.exe in command prompt. The prompt changes from $ to # (means root user). Run passwd command in Kali, change root password as usual. Now go back to previous registry key, change Zero to previous value (or 3e8 in hex). Here is an example of the registry values:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss] "DefaultDistribution"="" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\] "State"=dword:00000001 "DistributionName"="kali-linux" "Version"=dword:00000001 "BasePath"="C:\\MyFiles\\kali-linux" "KernelCommandLine"="BOOT_IMAGE=/kernel init=/init ro" "DefaultUid"=dword:000003e8 "Flags"=dword:00000007
Further details:
Сброс пароля для WSL Linux Distro в Windows 10
Если вы забыли пароль своей учетной записи в дистрибутиве WSL Linux и не можете войти в его консоль, то эта статья определенно будет вам полезна. Мы увидим, как сбросить пароль учетной записи в WSL Linux без использования сторонних инструментов.
Возможность запускать Linux изначально в Windows 10 предоставляется функция WSL. WSL означает подсистему Windows для Linux, которая изначально была ограничена только Ubuntu. Современные версии WSL позволяют устанавливать и запускать несколько дистрибутивов Linux из Microsoft Store.
После включения WSL вы можете устанавливать различные версии Linux из Магазина. Вы можете использовать следующие ссылки:
- Ubuntu
- openSUSE Leap
- SUSE Linux Enterprise Server
- Kali Linux для WSL
- Debian GNU/Linux
Когда вы впервые запускаете дистрибутив WSL, он открывает окно консоли с индикатором выполнения. Через некоторое время вам будет предложено ввести новое имя учетной записи пользователя и пароль. Эта учетная запись будет вашей учетной записью WSL по умолчанию, которая будет использоваться для автоматического входа при каждом запуске текущего дистрибутива. Кроме того, он будет включен в группу sudo, чтобы позволить ему запускать команды с повышенными привилегиями (как root).
Каждый дистрибутив Linux, работающий в подсистеме Windows для Linux, имеет своего собственного пользователя Linux. учетные записи и пароли. Вам придется настраивать учетную запись пользователя Linux каждый раз, когда вы добавляете дистрибутив, переустанавливаете или сбрасываете. Учетные записи пользователей Linux не только независимы для каждого дистрибутива, они также не зависят от вашей учетной записи пользователя Windows.
Чтобы сбросить пароль для WSL Linux Distro в Windows 10,
- Измените имя пользователя по умолчанию для вашего дистрибутива WSL на root. Используйте следующую команду: ubuntu config —default-user root . Для других дистрибутивов см. Примечание ниже.
- Запустите Linux распространение, например введите ubuntu или wsl , если вы работаете с дистрибутивом WSL по умолчанию.
- Сбросьте пароль с помощью команды passwd : passwd . Замените часть фактическим именем пользователя, для которого вы хотите сбросить пароль, например #passwd winaero .
- Выйдите из сеанса WSL и установите пользователь по умолчанию дистрибутива WSL обратно в свою учетную запись пользователя, например ubuntu config —default-user winaero .
Примечание. Используйте следующие команды, чтобы изменить своего пользователя по умолчанию на root в дистрибутиве WSL. Заменив ‘root’ другим имя учетной записи пользователя, вы установите ее в качестве учетной записи пользователя по умолчанию для дистрибутива.
- Ubuntu: ubuntu config —default-user root
- openSUSE Leap 42: openSUSE-42 config —default-user root
- SUSE Linux: SLES-12 config —default-user root
- Debian: debian config —default-user root
- Kali Linux: kali config —default-user root
Forgot Linux Password on WSL? Here’s How to Reset it Easily
Forgot the password of your Linux distribution app you installed in Windows via WSL? No worries. You can easily reset the Linux password in WSL.
WSL (Windows Subsystem for Linux) is a handy tool for people who want to enjoy the power of Linux command line from the comfort of Windows. When you install Linux using WSL on Windows, you are asked to create a username and password. This user is automatically logged on when you start Linux on WSL. Now, the problem is that if you haven’t used it for some time, you may forget the account password of WSL. And this will become a problem if you have to use a command with sudo because here you’ll need to enter the password. Don’t worry. You can easily reset it.
Reset forgotten password for Ubuntu or any other Linux distribution on WSL
- Switch the default user to root
- Reset the password for the normal user
- Switch back the default user to the normal user
Let me show you the steps in detail and with screenshots. If you want a video, you can watch that as well.
The root user in WSL is unlocked and doesn’t have a password set. This means that you can switch to the root user and then use the power of root to reset the password.
Since you don’t remember the account password, switching to the root user is done by changing the configuration of your Linux WSL application and make it use root user by default.
This is done through Windows Command Prompt and you’ll need to know which command you need to run for your Linux distribution.
This information is usually provided in the description of the distribution app in the Windows Store. This is from where you had downloaded your distribution in the first place.
From the Windows menu, start the command prompt:
In here, use your distribution’s command in this fashion. If you were using the Ubuntu app from Windows store, the command would be:
ubuntu config --default-user root
In the screenshot, I am using Ubuntu 20.04 app from the Windows store. So, I have used ubuntu2004 command.
To save you the trouble, I am listing some distributions and their respective commands in this table:
Distribution App | Windows Command |
---|---|
Ubuntu | ubuntu config –default-user root |
Ubuntu 20.04 | ubuntu2004 config –default-user root |
Ubuntu 18.04 | ubuntu1804 config –default-user root |
Debian | debian config –default-user root |
Kali Linux | kali config –default-user root |
Step 2: Reset the password for the account
Now, if you start the Linux distribution app, you should be logged in as root. You can reset the password for the normal user account.
Do you remember the username in WSL? If not, you can always check the contents of the /home directory. When you have the username, use this command:
It will ask you to enter a new password. When you type here, nothing will be displayed on the screen. That’s normal. Just type the new password and hit enter. You’ll have to retype the new password to confirm and once again, nothing will be displayed on the screen while you type the password.
Congratulations. The password for the user account has been reset. But you are done just yet. The default user is still root. You should change it back to your regular account user, otherwise, it will keep on logging in as the root user.
Step 3: Set regular user as default again
You’ll need the regular account username that you used with the passwd command in the previous step.
Start the Windows command prompt once again. Use your distribution’s command in the similar manner you did in step 1. However, this time, replace root with the regular user.
ubuntu config --default-user username
Now when you start your Linux distribution app in WSL, you’ll be logged in as a regular user. You have reset the password fresh and can use it to run commands with sudo.
If you forgot the password again in the future, you know the steps to reset it.
If resetting WSL password is this easy, is this not a security risk?
Not really. You need physical access to the computer and access to the Windows account. If someone already has this much access, they can do much more than just change the Linux password in WSL.
Were you able to reset WSL password?
I gave you the commands and explained the steps. I hope this was helpful to you and you were able to reset the password of your Linux distribution in WSL.
If you are still facing issues or if you have a question on this topic, please feel free to ask in the comment section.