How to set up a Remote Desktop GUI to a Debian Linux machine
Table of Contents
Run this code
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
Source: https://dev.to/darksmile92/linux-on-windows-wsl-with-desktop-environment-via-rdp-522g
Now you can log into it locally if you connect via Remote Desktop to localhost:3390
.
To allow other computers in your network to log into them, because it-s wsl2, you need to forward the connecton to the IP of the linux machine.
In linux run hostname -i
and that address is the one that you’ll use for the following command in the windows machine:
netsh interface portproxy add v4tov4 listenport=3390 listenaddress=0.0.0.0 connectport=3390 connectaddress=172.31.78.193
Make sure your laptop is discoverable in the network. Then you can log in via remote desktop from another computer in the same network by accessing to its local ip address.
To do so go to Advanced Firewall settings and create an inbound rule for port 3390 TCP that allows Private connections(make sure that the wifi is set to be a private network in both machines).
Troubleshooting
Me: xrdp Error message after login with username and password
ChatGPT said:
When using xrdp to connect to an Ubuntu server, you may encounter errors after entering your username and password. This can be due to various reasons, such as missing desktop environments, incorrect configurations, or permission issues. Here are some steps to troubleshoot and resolve common issues with xrdp: Step 1: Check the xrdp-sesman Log
The first step in troubleshooting is to check the log files for xrdp and xrdp-sesman, as they can provide detailed error messages.
sudo cat /var/log/xrdp-sesman.log
Me:
[20240901-11:02:39] [INFO ] Session started successfully for user sergio on display 10
[20240901-11:02:39] [INFO ] Session in progress on display 10, waiting until the window manager (pid 2494) exits to end the session
[20240901-11:02:45] [WARN ] Window manager (pid 2494, display 10) exited quickly (6 secs). This could indicate a window manager config problem
[20240901-11:02:45] [INFO ] Calling auth_stop_session and auth_end from pid 2493
[20240901-11:02:45] [INFO ] Terminating X server (pid 2495) on display 10
[20240901-11:02:45] [INFO ] Terminating the xrdp channel server (pid 2503) on display 10
[20240901-11:02:45] [INFO ] X server on display 10 (pid 2495) returned exit code 0 and signal number 0
[20240901-11:02:45] [INFO ] xrdp channel server for display 10 (pid 2503) exit code 0 and signal number 0
[20240901-11:02:45] [INFO ] cleanup_sockets:
[20240901-11:02:45] [INFO ] Process 2493 has exited
[20240901-11:02:45] [INFO ] ++ terminated session: username sergio, display :10.0, session_pid 2493, ip ::ffff:92.190.144.37:56691 - socket: 12
Chat GPT:
The log you provided indicates that the X server starts but then exits quickly, which suggests that there might be a problem with the window manager configuration or that the required desktop environment isn’t properly configured.
Here are steps you can take to troubleshoot and resolve this issue:
1. Check if a Desktop Environment is Installed
Make sure that you have a desktop environment installed. Xfce is a common choice for xrdp
because it is lightweight and works well with remote desktop sessions.
To install Xfce:
sudo apt update
sudo apt install xfce4 xfce4-goodies -y
2. Configure xrdp
to Use Xfce
If you’re using Xfce, you need to configure xrdp
to use it:
-
Create or edit the
~/.xsession
file in the user’s home directory:echo "xfce4-session" > ~/.xsession
-
Make sure that the
~/.xsession
file is readable by the user:chmod 644 ~/.xsession
-
Restart the
xrdp
service:sudo systemctl restart xrdp
3. Verify the Window Manager Configuration
The log mentions that the window manager exited quickly, which might indicate a misconfiguration.
To use Xfce with xrdp
, ensure that /etc/xrdp/startwm.sh
correctly calls the Xfce session:
-
Edit
/etc/xrdp/startwm.sh
:sudo nano /etc/xrdp/startwm.sh
-
Comment out the last two lines:
#. /etc/X11/Xsession #startxfce4
-
Add the following line before the script exits:
startxfce4
-
Save the file and exit the editor (
Ctrl + X
, thenY
, andEnter
). -
Restart the
xrdp
service again:sudo systemctl restart xrdp
4. Check Permissions
Ensure that your home directory and any relevant configuration files have the correct permissions:
-
Check ownership and permissions of your home directory:
sudo chown -R $USER:$USER /home/$USER
-
Ensure that
.Xauthority
has the correct ownership:sudo chown $USER:$USER ~/.Xauthority
5. Check Logs Again After Changes
If you continue to encounter issues, check the logs again after making these changes:
/var/log/xrdp-sesman.log
/var/log/xrdp.log
Look for any new errors or warnings that might provide further clues.
6. Consider Trying Another Desktop Environment
If Xfce doesn’t work or if you prefer another desktop environment, you can try installing GNOME or another lightweight desktop environment like LXDE or MATE.
For example, to install MATE:
sudo apt install ubuntu-mate-core -y
Then update your ~/.xsession
or /etc/xrdp/startwm.sh
to start the MATE session.
Summary
- Ensure a desktop environment (like Xfce) is installed.
- Configure
xrdp
to start the correct window manager. - Verify and fix file permissions.
- Check logs for further issues.
These steps should help resolve the issues you’re facing with xrdp
and allow you to establish a successful remote session.