0

使用 xrdp 遠端登入 Linux 桌面環境

 11 months ago
source link: https://blog.darkthread.net/blog/xrdp/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用 xrdp 遠端登入 Linux 桌面環境

calendar.svg 2023-05-26 11:07 PM comment.svg 0 eye.svg 2,034

Linux 我主要是拿來當 Server 用,在上面裝 Docker 跑 ASP.NET Core 網站,與 Windows 相比,Linux 的硬體需求低很多,自用排程或聊天機器人,1 CPU + 1G RAM 的 Azure B1s VM 就很夠用,每個月成本不到台幣三百元。

Linux 當伺服器用,靠 ssh 登入可搞定大小事,沒必要浪費 CPU、記憶體跟磁碟空間跑圖形化介面。我最近有個需求,軟體順帶安裝了 Grafana 及網頁管理介面,綁定 127.0.0.1 限本機瀏覽。是可以花點功夫 Nginx 設 Reverse Proxy 導到外部 IP,但接到 Internet 又扯到要不要限制來源 IP,有點小煩。想想,不如研究在 Linux 設定遠端桌面登入(Remote Desktop Protocol,RDP),未來玩 VM 就多了使用圖形化界面的選項。

Linux 常見的桌面環境有 GNOME、KDE 5、Unity、LXQt 等,我的目的單純,有 GUI 能開瀏覽器就好,不求功能豐富界面華麗,佔用資源愈少愈好。在此種考量下,Xfce 只需要 CPU 300MHz + 200MB RAM 就能跑 參考,同時也是 MS Learn 文件示範 Azure VM 遠端桌面採用的桌面環境。

我慣用 Debian,文件上的指令用 Ubuntu 示範,但大致可通用。現代 Linux 的生態環境比我想像成熟,照著指令敲完就設定好了,操作還算順,問題不多。(想起當年我玩的第一套 Linux 是 Slackware,那個年代要啟用某項功能或支援某種硬體,一言不合就得自己編譯 Linux 核心,我對 C 一竅不通,只會瞎查資料胡改亂設,不懂為何出錯也不曉得為什麼成功,一切交給天公伯 XD)

整理安裝指令如下:

# install xfce
sudo apt-get update
# 官方文件建議安裝 xfce,但實測有些小問題要排除(不確定是為因為我用 Debian)
# sudo DEBIAN_FRONTEND=noninteractive apt-get -y install xfce4
# 推薦裝 task-xfce4-desktop,內建 Firefox、RDP 可貼上指令
sudo apt-get -y install task-xfce4-desktop
sudo apt install -y xfce4-session       
# install remote desktop server
sudo apt-get -y install xrdp
sudo systemctl enable xrdp
# for Ubuntu 20
sudo adduser xrdp ssl-cert
# configure xfce as desktop environment
echo xfce4-session >~/.xsession
# restart xrdp
sudo service xrdp restart

若是 Azure VM,記得開放 3389 防火牆(建議鎖定來源 IP,避免被網路上的機器人攻擊),用平常連 Windows 的「遠端桌面連線」客戶端連上 Linux:

Fig1_638207109750580760.png

輸入帳號密碼進入 xfce 桌面,就能在 Linux 用瀏覽器連上本機站台囉~

Fig2_638207109756212910.png

同場加映,Chrome 安裝指令:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
google-chrome

【參考資料】

and has 0 comments

Comments

Be the first to post a comment

Post a comment

Comment
Name Captcha 41 + 35 =

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK