Linux – XRDP (remote desktop protocol)

Loading

測試環境為

  1. XRDP Server ( CentOS 8 ) – IP : 192.168.111.177
    測試環境建議可以先關閉 firewall 與 selinux https://benjr.tw/95368
  2. Windows Remote Desktop (Windows 10) – IP : 192.168.111.175

XRDP Server ( CentOS 8 ) – IP : 192.168.111.177

先來討論一下 Minimal Install 可以使用 XRDP 嗎?

我們得先了解 X-Window 的運作方式, X Server 負責顯示介面與繪圖,並將使用者的輸入行為告知 X Client,而 X client application 則是負責產生繪圖的數據並回傳給 X Server,通常我們的 display server 和 client application 都是在同一台電腦上面.

如果是使用最小安裝 (Minimal Install) 第一步需要幫 CentOS 安裝 GNOME 桌面系統 (GNOME Desktop),不可能一個一個套件安裝,可以直接透過 group install 即可.關於 group install 可以參考 https://benjr.tw/96155

[root@localhost ~]# yum groupinstall "Server with GUI"
[root@localhost ~]# reboot

預設的 YUM Repo 並沒有 xrdp 套件,需要新增 Repo 檔 (epel-release, Extra Packages for Enterprise Linux) .

[root@localhost ~]# yum install -y epel-release                                  
[root@localhost ~]# yum install -y xrdp

Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                         1/1 
  Installing       : xrdp-selinux-1:0.9.12-4.el8.x86_64                                                      1/2 
  Running scriptlet: xrdp-selinux-1:0.9.12-4.el8.x86_64                                                      1/2 
  Installing       : xrdp-1:0.9.12-4.el8.x86_64                                                              2/2 
  Running scriptlet: xrdp-1:0.9.12-4.el8.x86_64                                                              2/2 
  Verifying        : xrdp-1:0.9.12-4.el8.x86_64                                                              1/2 
  Verifying        : xrdp-selinux-1:0.9.12-4.el8.x86_64                                                      2/2 

Installed:
  xrdp-1:0.9.12-4.el8.x86_64                          xrdp-selinux-1:0.9.12-4.el8.x86_64                         

Complete!

我安裝的系統預設已經有 tigervnc-server-minimal ,如果 XRDP 無法使用可以直接安裝 tigervnc-server.

[root@localhost ~]# rpm -aq | grep -i vnc
tigervnc-license-1.9.0-12.el8_1.noarch
gvnc-0.9.0-1.el8.x86_64
tigervnc-server-minimal-1.9.0-12.el8_1.x86_64
libvncserver-0.9.11-9.el8.x86_64
gtk-vnc2-0.9.0-1.el8.x86_64
[root@localhost ~]# yum install -y tigervnc-server tigervnc-server-module

奇怪 XRDP 為什麼要 VNC ,在 https://github.com/neutrinolabs/xrdp 的 Remote Desktop Access 說明.

  • Connect to a Linux desktop using RDP from anywhere (requires xorgxrdp Xorg module)
  • Reconnect to an existing session
  • Session resizing
  • RDP/VNC proxy (connect to another RDP/VNC server via xrdp)

最後一項就是利用 xrdp 去連 VNC Server.

修改 xrdp 設定檔,在最後面加入 exec gnome-session

[root@localhost ~]# echo "exec gnome-session" >> /etc/xrdp/xrdp.ini

Enable (開機後起動服務) 與 start (立即起動服務) 並檢視其 status (狀態).

[root@localhost ~]# systemctl enable xrdp
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /usr/lib/systemd/system/xrdp.service.
[root@localhost ~]# systemctl start xrdp
[root@localhost ~]# systemctl status xrdp
● xrdp.service - xrdp daemon
   Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-03-06 23:07:09 CST; 5s ago
     Docs: man:xrdp(8)
           man:xrdp.ini(5)
 Main PID: 4232 (xrdp)
    Tasks: 1
   Memory: 964.0K
   CGroup: /system.slice/xrdp.service
           └─4232 /usr/sbin/xrdp --nodaemon

Mar 06 23:07:09 localhost.localdomain systemd[1]: Started xrdp daemon.
Mar 06 23:07:09 localhost.localdomain xrdp[4232]: (4232)(140048210073024)[INFO ] starting xrdp with pid 4232
Mar 06 23:07:09 localhost.localdomain xrdp[4232]: (4232)(140048210073024)[INFO ] address [0.0.0.0] port [3389] m>
Mar 06 23:07:09 localhost.localdomain xrdp[4232]: (4232)(140048210073024)[INFO ] listening to port 3389 on 0.0.0>
Mar 06 23:07:09 localhost.localdomain xrdp[4232]: (4232)(140048210073024)[INFO ] xrdp_listen_pp done

檢視一下 xrdp 使用 TCP : Port 3389

[root@localhost ~]# ss -tnlp | grep -i rdp
LISTEN   0         2                   0.0.0.0:3389             0.0.0.0:*        users:(("xrdp",pid=4232,fd=11))                                                
LISTEN   0         2                 127.0.0.1:3350             0.0.0.0:*        users:(("xrdp-sesman",pid=4231,fd=9))   

Windows Remote Desktop (Windows 10) – IP : 192.168.111.175

透過 Windows Remote Desktop Connection 就可以連了.

常見錯誤

預設的 YUM Repo 並沒有這些套件,需要新增 Repo 檔 (epel-release, Extra Packages for Enterprise Linux) .

[root@localhost ~]# dnf install xrdp 
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:34:24 ago on Fri Mar  6 21:45:47 2020.
No match for argument: xrdp
Error: Unable to find a match: xrdp
[root@localhost ~]# yum install xrdp
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:34:36 ago on Fri Mar  6 21:45:47 2020.
No match for argument: xrdp
Error: Unable to find a match: xrdp
沒有解決問題,試試搜尋本站其他內容

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料