Logging in after remoting to my ubuntu pc shows a black screen

I am new to RDP setups, I have my mac setup to remote into my ubuntu PC (22.04.3 LTS) when I am at my University and it works fine. The only problem I am having is that after closing the connection, when I try to log back in to my Ubuntu PC in person I am faced with a black screen and I am unable to do anything, on restart this issue fixes itself and I can login normally.

I have been searching for any potential solution but I think I am not wording my search properly and hence can’t find any help online. Any help would be much appreciated, Thanks.

Asked By: aniket32

||

The Cause

The xrdp and gnome protocols only allows for a single GUI session. This means you can either login locally or login using xrdp, but not both. The "easy" solution is to logout from the xrdp session. Unfortunately, sometimes we forget to do that.

For example, if you are logged in locally you cannot login remotely using xrdp. Conversely, if you are logged in remotely using xrdp, you cannot login locally. This limitation of xrdp may be removed in a future version.

The Solution

The following process works on Ubuntu 23.10. I have tested it on a virtual machine.

Open a local virtual terminal

Remotely connect to the local computer using xrdp.

Physically go to the remote computer. You won’t be able to login using the GUI method. Open a virtual terminal (a keyboard only interface) by pressing Ctrl+Alt+F3. This will open a black screen with a prompt:

login:

Enter your username and press enter and enter your password when prompted. You won’t see the cursor move or any **** when you enter the password. This is normal.

Find the list of sessions

Now at the terminal enter the following command:

loginctl list-sessions

You will see something like this as output:

SESSION  UID USER      SEAT  TTY 
      2 1000 aniket32  seat0 tty3
     c1 120  gdm       seat0 tty1
     c2 1000 aniket32

3 sessions listed.

Note the SESSION ID of the user aniket32 that does not have any SEAT and TTY. In the above example, it is c2. Yours may be different.

Kill the remote session

When you do this any unsaved changes to files you may have open will be lost.

Now use the following command to kill this session:

sudo loginctl kill-session c2

Enter your password when prompted.

This should kill the remote xrdp session. If the remote xrdp connection was active, it will close with this command.

Log out of the virtual terminal

Now you can logout of the virtual terminal "TTY3" by typing logout Enter. Alternately by pressing the key combination Ctrl+D.

Login normally

To get back to the GDM login screen press Ctrl+Alt+F1. Now you should see your normal login screen and login as usual.

Alternate Solution

source: Local Ubuntu desktop cannot login after opened Xrdp session

Login locally on the remote computer while you are not logged in using xrdp. Open the file /etc/xrdp/sesman.ini using using `sudo:

sudo nano `/etc/xrdp/sesman.ini`

Look for the line:

KillDisconnected=false

and make it look like:

KillDisconnected=60s

Save the changes by pressing Ctrl+S. Exit nano by pressing Ctrl+X.

The changes won’t take effect until xrdp is restarted. Restart the xrdp service by:

sudo systemctl restart xrdp.service

After this change, once you disconnect your remote xrdp connection without logging out remotely, the remote session will be closed after 60 seconds. That is, any unsaved changes to files you may have open will be lost. On the plus side, you will be able to login locally.

Hope this helps

Answered By: user68186
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.