Black Screen Remote Desktop to Ubuntu from Windows with XRDP

We have noticed that a lot of people hit the same issue over and over again. When trying to connect via remote desktop protocol (rdp) to the Ubuntu machine, and after providing the credentials in the xRDP Login page, the user will only see a black screen displayed and the desktop interface is never loaded and displayed. This post will basically explain why this happens and how to reproduce the issue.

Black Screen when Remote Desktop to Ubuntu

Let’s assume that you have installed xRDP to enable Remote Desktop service on an Ubuntu machine. And you are still logged on into your Ubuntu machine system locally with your user account.

Now, you move to a Windows machine then connect to the Ubuntu using RDP.

If the credentials are correct, you will see your remote desktop session showing a black screen.

Remove Black Screen when Remote Desktop to Ubuntu

This situation will happen (or can happen) when the same user account is used concurrently locally and remotely. In other words, the problem is related to the fact that the same user account is already logged in locally and a remote connection is attempted at the same time.

To solve this issue, there is a simple fix. You need to ensure the account you are using to login via the remote desktop client is not currently logged on locally on the Ubuntu target machine. If this is the case, perform a logout operation.

Try again the remote desktop session and you will be able to perform your remote desktop connection and that your desktop interface will be loaded and made available for you.

Allow multiple sessions (local and remote) for the same user

If you don’t want to logout the current user, you can allow a user to login via xRDP even if the same user account is already logged on locally on the Ubuntu machine.

Method 1: Using dbus-launch approach

You will simply need to modify your /etc/xrdp/startwm.sh file and appending a one liner that will allow you to basically acquire the desktop while performing your remote connection even if you are already logged on locally. To implement this trick, simply open the /etc/xrdp/startwm.sh with your favorite text editor.

sudo nano /etc/xrdp/startwm.sh

At the below line before this line test -x /etc/X11/Xsession && exec /etc/X11/Xsession. Then save the file.

Tip: To save the file in nano editor, press

> >

export $(dbus-launch)
#!/bin/sh
# xrdp X session start script (c) 2015, 2017 mirabilos
# published under The MirOS Licence

if test -r /etc/profile; then
        . /etc/profile
fi

...
export $(dbus-launch)
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

Restart the xrdp service to take the change goes into effect.

sudo systemctl restart xrdp

Method 2: unsetting DBUS_SESSION_BUS_ADRESS

This method is similar to the first one. You will also need to edit and modify the /etc/xrdp/startwm.sh file and add some additional commands to be executed when the remote session will be initiated.

At the below line before this line test -x /etc/X11/Xsession && exec /etc/X11/Xsession. Then save the file.

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
#!/bin/sh
# xrdp X session start script (c) 2015, 2017 mirabilos
# published under The MirOS Licence

if test -r /etc/profile; then
        . /etc/profile
fi

...
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

Now, you can give it a try.  Stay logged on locally on the machine and initiate your remote session.

Method 3:

Add the following line at the begin of the file /etc/xrdp/startwm.sh.

#Improved Look n Feel Method
cat <<EOF > ~/.xsessionrc
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
EOF

Tip: To save the file in nano editor, press

> >

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值