Ubuntu (Linux) Desktop using RDP GUI with Windows WSL
This article explains the steps to setup Ubuntu virtual machine with Desktop environment on Windows using Window's Subsystem for Linux (WSL) and be able to connect to Ubuntu using Window's builtin Remote Desktop Protocol (RDP) app.
Enable WSL on Windows:
Through GUI:
- Start -> Search -> Turn Windows feature on or off
- Virtual Machine Platform -> Tick
- Windows Hypervisor Platform -> Tick
- Window Subsystem for Linux -> Tick
- Click OK
- Wait for some installations to complete
- Restart Windows
Through Terminal:
Install Ubuntu:
Start -> Terminal and execute
wsl.exe --update
wsl.exe --install -d Ubuntu
When prompted 'Create a default Unix user account' give any username like 'ubuntu'
Type a password
Retype the password
Wait for installation to complete
Verify Ubuntu:
wsl.exe --list --verbose
Launch Ubuntu:
wsl.exe -d Ubuntu
or through UI
Start -> Ubuntu
Setup GUI for RDP:
Update packages using commands
sudo apt-get update
sudo apt-get upgrade -y
Install and setup tasksel:
sudo apt-get install -y tasksel
sudo tasksel
Use Up and Down Arrows to choose the Desktop environment. KDE Plasma seems to be the most stable flavour for xrdp remote session and it also supports using multiple monitors out of the box, but feel free to explore other desktop environments like GNOME or Xfce. Select only one desktop environment, as selecting multiple causes configuration issues.
Use Space key to tick or untick
Use Tab bar to go to OK button
Press Space key to click OK button
Wait for the tasksel command to complete desktop installation and setup, as this will take a long time to complete.
Install chromium browser:
The default browser firefox doesn't work with xrdp session, hence installing chromium will help in windows RDP session
sudo apt-get install -y chromium
Install xrdp:
sudo apt-get install -y xrdp
Configure and restrict xrdp connection:
Edit the following file to restrict xrdp connection, so that RDP connection is allowed only from Windows Host and the port change to avoid port clash with Window's built in RDP settings
sudo nano /etc/xrdp/xrdp.ini
- If address entry is already present, then change the existing address entry, otherwise add an address entry as address=127.0.0.1
- If port entry is already present, then change the existing port entry, otherwise add a port entry as port=3390
- Save and exit (Ctrl+O, Enter, Ctrl+X)
sudo nano /etc/xrdp/startwm.sh
Add the following lines before the last line (usually before test -x /etc/X11/Xsession)
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
Save and exit (Ctrl+O, Enter, Ctrl+X)
Enable and restart the xrd service:
sudo systemctl enable xrdp
sudo systemctl restart xrdp
Restart Ubuntu virtual machine from a new Windows Terminal:
Terminate single Ubuntu virtual machine
wsl.exe --terminate Ubuntu
or
Shutdown entire wsl instances
wsl.exe --shutdown
Check shutdown status
wsl.exe --list --verbose
Start Ubuntu virtual machine and check xrdp service status
wsl.exe -d Ubuntu
sudo systemctl status xrdp
Connect from Windows using RDP:
Start -> Search -> Remote Desktop Connection
Enter the Computer as localhost:3390 and connect
Select the Session type as Xorg and enter the Ubuntu username and password when prompted
Type in the Ubuntu password once again if prompted
Display Options:
- To avoid launching the session in full screen mode, Display Tab -> Start Session in Fullscreen -> Untick
- To use multiple monitors / dual screen, Display Tab -> Use all monitors -> Tick
Changing the memory allocation to Ubuntu
Changing password of Ubuntu user:
Clean up of WSL and distributions:
Delete a particular virtual machine:
wsl.exe --unregister Ubuntu
Delete all virtual machines:
wsl.exe --list --quiet | ForEach-Object { wsl --unregister $_ }
Uninstall wsl application itself:
wsl.exe --uninstall
Directory Sharing between Windows and Ubuntu:
Full Sharing (Default):
Making Windows Directory as Read Only:
No Sharing (Complete Isolation):
Sharing only single directory:
Using WSL version 1 (Legacy):
If you get the following error
WSL2 is not supported with your current machine configuration.
Please enable the "Virtual Machine Platform" optional component and ensure virtualisation is enabled in the BIOS.
Enable "Virtual Machine Platform" by running: wsl.exe --install --no-distribution
For information please visit https://aka.ms/enablevirtualization
Error code: Wsl/InstallDistro/Service/RegisterDistro/CreateVm/HCS/HCS_E_HYPERV_NOT_INSTALLED
Try using legacy version 1 of wsl
wsl.exe --set-default-version 1
wsl.exe --install -d Ubuntu
Comments
Post a Comment