WSL (Windows Subsystem for Linux) is very common these days especially with the new that Windows will ship a Linux kernel with WSL 2.0!
Installing a Linux distro as WSL is easy via the Microsoft App Store and there are plenty of tutorials out there for it.
Most of the resources cover the access via Shell, Terminal, Hyperterminal or other console based tools to the WSL.
Running GUI software is possible and there are resources describing how to archieve this via VcXsrv (see chapter in this post of mine).
But what if you:
Want to have/access a Desktop environment on WSL?
You can use any Desktop Environment you want, I will be using Xfce in this example because it is lightweight.
Here is the quick rundown of all commands and steps, explained in the sections below. One is for Kali Linux, the other is for the Debian based distros (Debian, Ubuntu, ...).
For Kali:
sudo apt update && sudo apt -y upgrade
sudo apt -y install kali-desktop-xfce
sudo apt-get install xrdp
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
sudo /etc/init.d/xrdp start
EDIT: 08/2022
As Elvis Van mentioned in the comments, there is a package for Kali linux now targeting specifically this case: kali-win-kex. It takes care of the full setup of all Kali components and configurations to give you the Kali Desktop experience under WSL2.
For other debian based distros:
sudo apt update && sudo apt -y upgrade
sudo apt -y install xfce4
sudo apt-get install xrdp
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
sudo /etc/init.d/xrdp start
And then connect via RDP localhost:3390
to your desktop.
Detailed steps
Updating the system and installing Xfce4
sudo apt update && sudo apt -y upgrade
sudo apt -y install kali-desktop-xfce
sudo apt -y install xfce4
The first command updates the source list and the packages. Always important, I will not explain this.
The sudo apt -y install kali-desktop-xfce
installs a Kali Linux specific version of Xfce4 and sudo apt -y install xfce4
will install the Xfce4 package for debian based distros.
Installing Xrdp
sudo apt-get install xrdp
Xrdp is an open source remote desktop solution and also very lightweight and easy to configure. This command will install the package and setup the default configuration with port 3389.
Configuring Xrdp
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
sudo /etc/init.d/xrdp start
Copy the config file as backup before the changes, change the port from 3389 to 3390 and for quality reasons increase the bpp from 24 to 128. You can play with those settings but since this is a local connection, the speed should not be worse with those settings.
And finally restarting the xrdp service to apply the changes.
Now you can connect via localhost:3390
and the credentials of your WSL account via RDP! 💪
Why the port change from 3389 to 3390?
Two reasons: security and sometimes port 3389 is used by a process on wsl and you get the message
Your computer could not connect to another console session on the remote computer because you already have a console session in progress.
Benefits of RDP here
Even though you can run GUI software via XServer in a window, sometimes it is more convenient to have the full desktop environment accessible.
Also you can restore a previously disconnected session easily and do not have to close the console (let processes running for example).
Let me know your thoughts on this topic!
Latest comments (64)
not able to connect after last command it showing starting rdp but couldnt connect to remote desktop
well everything is fine except whenever I connect RDP it opens WINDOWS
any solution?
update on 8/2022, there's a new kali-specific package for this called kali-win-kex, it's been pretty smooth and a lot more easy to setup than this
Thanks! I updated the post referencing your comment.
Is there a way to modify this procedure to use GNOME instead of xfce? I've tried putting
gnome-session
in~/.xsession
instead ofstartxfce4
, as well as anything else I can think of, but it's not working.i just change the port from 3390 to 3400 and it still dont work.
I have followed all the above instruction and it works till when I log in my credentials then after that it output 'unable to contact settings server, failed to execute child process "dbus-launch" (no such file or directory)' pls I need it been trying to fix it for months now,
thank u
This reddit thread seems to have a solution that worked for a couple of people, maybe try it with this:
I have followed all the above instruction and it works till when I log in my credentials then after that it output 'unable to contact settings server, failed to execute child process "dbus-launch" (no such file or directory)' pls i need it been trying to fix it for months now,
thank u
hello, pls I followed the procedure u gave up but when I log in to RDP after putting in my credentials then it will go blank and output a message, 'unable to connect settings server. failed to execute child process"dbus-launch" (no such file or directory)'
pls i have followed all the procedure but after assigning my credentials is now showing 'unable to connect settings server, failed to execute child process "dbus-launch" (no such file or directory)' can anyone help me solve this issue.
thank u
I installed configured xrdp and xfce4
I started xrdp and can connect using remote desktop
I can log in but the session is not starting - just a blank green background and eventually an error message
Connectiong to sessman ip 127.0.0.1 port 3350
sessman connect ok
sending login info to session manager, please wait...
started connecting
connection problem, giving up
some problem