WSL2 continues to be one of my top features I want to explore and learn more about in the entire Windows 10 offering. What Microsoft is doing with WSL is fascinating and the endless possibility of having Linux and Windows in such deep marriage is beyond my wildest dream.
In today’s guide, we will use Window’s native RDP client to remote connect into your local WSL2 Ubuntu on the same machine. (when is the last time you RDP into localhost? … and the destination is also running in Linux, not Windows) This never happened to me until just recently. Below is a sneak peek of the end result. Let’s get started.
We assume by now you already have WSL2 running and have at least Ubuntu installed. You can follow this guide to upgrade your Ubuntu to the latest 20.04 LTS distro if you haven’t already done so.
First the standard
sudo apt update && sudo apt -y upgrade
Next we are going to install a GUI distro to Ubuntu
sudo apt-get install -y kubuntu-desktop
Half way through the installation you will be prompt for this configurating sddm, select lightdm
Install and configure XDRP, and change the RDP port to 3390
# install xrdp
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
Lastly, enable Dbus
#enable dbus
sudo systemctl enable dbus
sudo /etc/init.d/dbus start
sudo /etc/init.d/xrdp start
# check xrdp status
sudo /etc/init.d/xrdp status
You should see something like this below.
Now launch your Windows Remote Desktop Connection, or mstsc
from the Windows Start menu.
enter localhost:3390
and connect. You will be prompt by this screen keep the session as xorg, and enter your WSL2 username and password.
That’s it, you are now connected to your WSL2 Ubuntu with a GUI over Windows’ native RDP client. How crazy is this?!
All above steps went well
RDP is crashing!
any idea?
what do you mean by RDP is crashing? what do you see on the screen? any error messages?
Same for me
—————————————————-
Note: lines starting with “>” are terminal commands
—————————————————-
If xrdp is running, stop it via:
> sudo /etc/init.d/xrdp stop
Edit the startwm.sh file:
> sudo nano /etc/xrdp/startwm.sh
Comment out the following two lines by adding a “#” at the beginning of each line:
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession
Below the now commented lines, add:
startxfce4
Save the file, start xrdp with
> sudo /etc/init.d/xrdp start
Now you should be able to start the remote desktop session on windows and login with your linux username and password
Great!!! My xfce is running ok now with this tip. Thanks
thank you. the tips work!
it is a great help
I still have the same problem, but now it only crashes after 30 seconds.
this worked for me:
sudo apt install xfce4-session
This is great for xfce but what budgie? Do I just add “startbudgie” where “startxfce4” is? Please help. Thanks
Yess, it works now!!
Everything works as expected now.
Thank you, Julius!
Perfect! Thanks very much.
I have tried all this but I am getting a blank screen
Thank you for the solution to my problem.
—————————————————-
Note: lines starting with “>” are terminal commands
—————————————————-
If xrdp is running, stop it via:
> sudo /etc/init.d/xrdp stop
Edit the startwm.sh file:
> sudo nano /etc/xrdp/startwm.sh
Comment out the following two lines by adding a “#” at the beginning of each line:
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession
Below the now commented lines, add:
startxfce4
Save the file, start xrdp with
> sudo /etc/init.d/xrdp start
Now you should be able to start the remote desktop session on windows and login with your linux username and password 🙂
still having issues connecting via rdp. The remote desktop tries to connect and then says: Remote Desktop cannot connect to the remote computer
When running this command it says xrdp is running so not sure what the problem is:
service xrdp status
* xrdp-sesman is running
* xrdp is running
After installing the following:
$sudo apt install xfce4 xfce4-goodies
follow every step from author then remote desktop works perfectly. You also can use VNC Viewer from
other computers or phone.
follow the reference:
How to Install and Configure VNC on Ubuntu 20.04
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04
Remote connection is getting authorized but immediately getting closed.
@Julius’ method can solve this problem!
That didn’t work either. I am using ubuntu-desktop
Mostly this error occurs if you are already logged in via a local session. You cannot login twice. Logout your local session, then you can connect via RDP.
where are my files being saved to on my windows pc with this method?
cd /mnt is how you access your windows files in Ubuntu. So you can ideally go to your windows Desktop by doing cd /mnt/c/Users/yourwindowsusername/Desktop/
Hope that helps!
With
sudo apt install xfce4 xfce4-goodies
and rest of the guide, everything worked for me
it’s finally working, thanks a lot.
I did the above guide but it didn’t work until I edited the file and installed the repositories.
late to this party. followed the guide, followed the commented changes. one major difference for me: lightdm was not a display manager option gdm-3 was.
at the end of it all, I can connect, but only get a black screen. following the guide to install vnc and enable a connection via an ssh tunnel, all I get is an xwindows gray screen and cursor.
it’s like the window server is running, but no windowing agent on the other side so it connects to a blank space.
any ideas? Start over? 😛
Here’s a one-line install script from GitHuib that will do all of this for you automatically:
https://github.com/DesktopECHO/kWSL <– KDE Neon
https://github.com/DesktopECHO/xWSL <– Ubuntu 20.04 with Xfce 4.16
Failed. Connected to port 3350 instead of 3390, despite resetting it to 3390.
“connecting to sesman ip 127.0.0.1 port 3350
sesman connect ok
sending login info to session manager, please wait…
login failed for display 0”
Clicking OK just launched another login window.
What happened? I retraced all of my commands, they were correct.
Same here, how did you fix it ?
that is because username is incorrect
Thank you thank you thank you.
New to Linux, using WSL2 under Win 10 Pro
Your answer worked for me, about the 8th or 9th attemp
Hi, I followed all instructions above and I am able to have the login page in the rdp. I enter in my wsl2 credentials and click the “OK” button but it doesn’t do anything (it only made the border looked dashed). I have searched around but I found only one question which wasn’t answered https://askubuntu.com/questions/1335984/stuck-on-login-screen-ubuntu-20-04-xrdp-windows-10-remote-desktop. Please help.
I’ve just started using it. It worked but I can’t see anything after logging in. Just a cyan background
Hi,
Great method, but I’m having a small problem. If remote desktop stays idle, I receive a black screen. Then I have to enter the command; ‘sudo /etc/init.d/xrdp stop’ and that ‘sudo /etc/init.d/xrdp start’ to be able to use the remote desktop again.
Is there a fix for that?
Thanks
Hi,
The instructions above worked for me, after combining it with some suggestions in the comments. What I still wonder is whether it’s necessary to encrypt the connection to the local RDP. By default the encryption is ‘high’, for performance reasons i would like to make it ‘none’. Is this wise?
I have tried all this but I am getting a blank screen
Is it possible to get audio to work ?
In
Windows 10 RDP client -> Show Options -> Local Resources ->Configore remote audio settings -> Settings
you can configure Play on this computer (Do not play or Play on remote computer)
But I can’t get any of them to work.
In my Home dir in wsl 2 Ubuntu 21.04 I can find “.xession-errors” which mentions
”
XRDP_PULSE_SINK_S0CKET=xrdp_chansrv_audio_out_socket_24
XRDP_PULSE_S0URCE_S0CKET=xrdp_chansrv_audio_in_socket_24
PULSE_SCRIPT=/etc/xrdp/pulse/default.pa
org.kde.plasma.session: Starting autostart service “/etc/xdg/autostart/pulseaudio.desktop” (“/bin/start-pulseaudio-xll”)
”
But no audio gets through.
Can that be solved ?
—
Eigil
Just recently found gWSL (grafical WSL2) from the Windows store, with it the setup works great, while before I had some issues with Linux GUI apps
Yes, they are slightly different, while WSLg gives you the ability to run Linux-based GUI apps, it doesn’t allow you to ‘RDP’ or ‘VNC’ into a full-blown GUI Linux. But the question is why you need to do that if you can run Linux GUI apps side by side of Windows.
I managed to get it kind of running by executing sudo apt install xfce4-session and then restarting the services
Thanks tthis helped me and works for me
Can we remote with the another machine?
Thank you very much. Now is working ok. Thanks a lot again.
Hey,
This is working great. Is it possible to change the GUI to Gnome? Thanks, Paul.
Nice works well, not that I will use it much, but it was fun to try…
All work well on my windows 11. But on the desktop session to Ubunuto 22.04 I am not able to add programs or configure and save updated configurations.
Any idea?
Failed to restart acpid.service wsl
systemctl commands did not work for me on WSL2 Ububtu 22.04. Seems dbus is already enabled so “service dbus start” worked,
I managed to get mine working with the steps provided above! Thank you so much for the help, Jonathan Hu! 😀 (The only difference is that I used the ubuntu-desktop (Gnome) DE instead of the kubuntu-desktop (Plasma) DE. :))
I installed the package, but the terminal was running much slow and an error notification that says wslhost.exe error encountered wsl startup.
Can somebody help please?