It appears you're encountering an issue when trying to connect to your Ubuntu 22.04 machine via Remote Desktop Protocol (RDP). The error message:
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
indicates that while the connection to the xrdp session manager (sesman) is successful, the actual login session is failing. This is a common issue and can often be resolved by ensuring that your RDP server (xrdp) and desktop environment are properly configured.
Here's a step-by-step guide to help you resolve this issue:
1. Install XRDP and a Desktop Environment
First, ensure that xrdp and a desktop environment are installed on your Ubuntu machine. Since Ubuntu 22.04 uses GNOME with Wayland by default (which isn't fully compatible with xrdp), it's recommended to use an alternative desktop environment like XFCE.
Install XRDP and XFCE:
sudo apt update
sudo apt install xrdp xfce4 xfce4-goodies -y
2. Configure XRDP to Use XFCE
To configure xrdp to use the XFCE desktop environment:
Create a .xsession File in Your Home Directory:
echo xfce4-session > ~/.xsession
Alternatively, Modify the xrdp Startup Script:
Edit the startwm.sh file:
sudo nano /etc/xrdp/startwm.sh
Add the following lines before the last line (exit 1):
# Start XFCE
startxfce4
So the script looks like:
#!/bin/sh
if [ -r /etc/profile ]; then
. /etc/profile
fi
# Add this line to start XFCE
startxfce4
Save and exit the editor (Ctrl+O, Enter, Ctrl+X).
3. Add xrdp User to ssl-cert Group
This step ensures that xrdp has the necessary permissions:
sudo adduser xrdp ssl-cert
4. Restart XRDP Service
After making the configuration changes, restart the xrdp service:
sudo systemctl restart xrdp
5. Disable Wayland (If Necessary)
If you prefer to use GNOME instead of XFCE, you need to disable Wayland since xrdp doesn't support Wayland sessions.
Edit the GDM Configuration File:
sudo nano /etc/gdm3/custom.conf
Uncomment the line WaylandEnable=false so it looks like:
WaylandEnable=false
Save and exit the editor.
Restart the GDM3 Service:
sudo systemctl restart gdm3
6. Ensure Xorg Session is Used
If using GNOME, make sure your user session is set to use Xorg instead of Wayland.
7. Verify Firewall Settings
Ensure that port 3389 (the default RDP port) is open on your Ubuntu machine:
sudo ufw allow 3389/tcp
8. Try Connecting Again
Now, attempt to connect to your Ubuntu machine using Remote Desktop from your client. Use your Ubuntu username and password when prompted.
Additional Troubleshooting Steps
If you're still experiencing issues, consider the following:
Check XRDP and Sesman Logs
These logs can provide detailed information about why the connection is failing.
View XRDP Log:
sudo cat /var/log/xrdp.log
View XRDP Sesman Log:
sudo cat /var/log/xrdp-sesman.log
Look for any errors or warnings that might indicate what's going wrong.
Ensure Correct Credentials
Double-check that you're using the correct username and password. Remember that Linux usernames and passwords are case-sensitive.
Verify User's Home Directory
Make sure that the user account you're logging in with has a home directory and appropriate permissions.
Restart the System
Sometimes, services need a full system reboot to apply changes:
sudo reboot
Check XRDP Service Status
Ensure that xrdp is running properly:
sudo systemctl status xrdp
You should see that the service is active and running.
Explanation of the Issue
-
XRDP and Wayland: By default, Ubuntu 22.04 uses Wayland for its display server, but XRDP doesn't support Wayland sessions. This incompatibility can cause the login session to fail. Switching to Xorg resolves this issue.
-
Desktop Environment Compatibility: Some desktop environments are more compatible with XRDP. XFCE is lightweight and works well with XRDP.
-
Permissions: The xrdp user needs appropriate permissions to create sessions. Adding it to the ssl-cert group helps in resolving permission issues.
Summary
By installing a compatible desktop environment (like XFCE), configuring XRDP to use it, ensuring the XRDP service has appropriate permissions, and disabling Wayland if necessary, you should be able to resolve the "login failed for display 0" error and successfully connect to your Ubuntu machine via Remote Desktop.
If you continue to experience issues after following these steps, please provide any error messages from the XRDP logs (/var/log/xrdp.log and /var/log/xrdp-sesman.log), and I'll be happy to help you troubleshoot further.