星期四, 19 6 月, 2025
No Result
View All Result
育心文具行

育心文具行

  • 首頁
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 我的工具箱
  • 關於我
育心文具行
  • 首頁
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 我的工具箱
  • 關於我
No Result
View All Result
育心文具行
Home 筆記x備忘

製作 Ubuntu 遠端桌面伺服器

2023-10-05
in 筆記x備忘
Reading Time:3 mins read
A A
0

有時我們會需要安裝一個雲端的伺服器是有 GUI 介面可以操作的,舉例像是用模擬器爬爬蟲,或是需要遠端協作需求的人,會需要在雲端伺服器上安裝一個桌面伺服器。

先提一下會有缺點:

  1. 通常雲端 VPS 廠商不會有顯卡,所以遠端桌面勢必顏色和顯示上不會太好。
  2. 雲端廠商的規格和價格成正比,勢必無法和自己使用電腦上比較。
  3. 即便使用 GUI 介面,他畢竟是一台伺服器,你能連上表示其他人也能連,常常很容易忽略了伺服器需要設定的安全機制。

這邊使用 Linode Ubuntu 22.04 安裝,安裝目標:

  1. Gnome desktop 環境
  2. XRDP 遠端桌面連線

捨棄 Linode 文件中描述的 VNC 連線,是因為怎麼裝都連不起來…曾經懷疑是不是 Gnome 安裝錯了,後來發現根本是 VNC 設定有問題,果斷使用 XRDP 來處理。

步驟:

  1. 首先參照 Linode 文件 確認購買一個伺服器,並且設定好伺服器時區\hostname\更新等等。
  2. 如果不使用 tasksel 安裝,則使用以下指令:
    sudo apt install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
  3. 如果使用 tasksel 安裝,請參考這裡 :
    sudo apt install tasksel
    sudo tasksel install ubuntu-desktop
  4. 安裝 xrdp 功能,文件中使用的 OS 是 ubuntu 18.04 不過用 22.04 也行的:
    sudo apt-get install xrdp -y
  5. 如果使用 ufw 套件(可用 ufw status 或是 iptabes -h 指令檢查):
    sudo ufw allow 3389/tcp
  6. 如果使用 iptables 套件:
        1. 編輯設定檔案:
          nano /etc/v4
        2. 輸入內容並儲存(注意要開啟 3389 port):
          *filter
          
          
          # Allow all loopback (lo0) traffic and reject traffic
          # to localhost that does not originate from lo0.
          -A INPUT -i lo -j ACCEPT
          -A INPUT ! -i lo -s 127.0.0.0/8 -j REJECT
          
          
          # Allow ping.
          -A INPUT -p icmp -m state --state NEW --icmp-type 8 -j ACCEPT
          
          
          # Allow SSH connections.
          -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
          
          
          # Allow HTTP and HTTPS connections from anywhere
          # (the normal ports for web servers).
          #-A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
          #-A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
          -A INPUT -p tcp --dport 3389 -m state --state NEW -j ACCEPT
          
          # Allow inbound traffic from established connections.
          # This includes ICMP error returns.
          -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
          
          
          # Log what was incoming but denied (optional but useful).
          -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables_INPUT_denied: " --log-level 7
          
          
          # Reject all other inbound.
          -A INPUT -j REJECT
          
          
          # Log any traffic that was sent to you
          # for forwarding (optional but useful).
          -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "iptables_FORWARD_denied: " --log-level 7
          
          
          # Reject all traffic forwarding.
          -A FORWARD -j REJECT
          
          
          COMMIT
        3. 編輯設定檔案:
          nano /etc/v6
        4. 輸入內容並儲存:
          *filter
          
          
          # Allow all loopback (lo0) traffic and reject traffic
          # to localhost that does not originate from lo0.
          -A INPUT -i lo -j ACCEPT
          -A INPUT ! -i lo -s ::1/128 -j REJECT
          
          
          # Allow ICMP
          -A INPUT -p icmpv6 -j ACCEPT
          
          
          # Allow HTTP and HTTPS connections from anywhere
          # (the normal ports for web servers).
          #-A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
          #-A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
          
          
          # Allow inbound traffic from established connections.
          -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
          
          
          # Log what was incoming but denied (optional but useful).
          -A INPUT -m limit --limit 5/min -j LOG --log-prefix "ip6tables_INPUT_denied: " --log-level 7
          
          
          # Reject all other inbound.
          -A INPUT -j REJECT
          
          
          # Log any traffic that was sent to you
          # for forwarding (optional but useful).
          -A FORWARD -m limit --limit 5/min -j LOG --log-prefix "ip6tables_FORWARD_denied: " --log-level 7
          
          
          # Reject all traffic forwarding.
          -A FORWARD -j REJECT
          
          
          COMMIT
      1. 執行指令:
        iptables-restore < /etc/v4;/sbin/iptables-save;ip6tables-restore < /etc/v6;/sbin/ip6tables-save;
  7. 設定 polkit 添加授權規則,編輯檔案:
    sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf
  8. 輸入以下內容後儲存,這主要功能是色彩管理避免需要多次輸入密碼:
    polkit.addRule(function(action, subject) { if ((action.id == "org.freedesktop.color-manager.create-device" || action.id == "org.freedesktop.color-manager.create-profile" || action.id == "org.freedesktop.color-manager.delete-device" || action.id == "org.freedesktop.color-manager.delete-profile" || action.id == "org.freedesktop.color-manager.modify-device" || action.id == "org.freedesktop.color-manager.modify-profile") && subject.isInGroup("{group}")) { return polkit.Result.YES; } });
  9. 重啟 XRDP:
    sudo /etc/init.d/xrdp restart

連線時 windows OS 用戶使用內建的遠端桌面連線工具即可, MacOS 用戶推薦使用 Microsoft Remote Desktop 這套軟體。

其他額外你可能需要的東西

  1. 安裝 Chrome: https://linuxize.com/post/how-to-install-google-chrome-web-browser-on-ubuntu-20-04/
  2. 安裝 Telegram:https://linuxhint.com/install-telegram-desktop-messenger-linux/

 

參考文件:

  1. https://www.linode.com/docs/guides/set-up-and-secure/
  2. https://www.linode.com/docs/guides/install-vnc-on-ubuntu-20-04/
  3. https://operavps.com/linux-vps-with-gui-and-rdp/
  4. https://documentation.suse.com/zh-cn/sles/15-SP2/html/SLES-all/cha-security-policykit.html
Tags: 22.04linuxrdpubuntuvncvpsxrdp
Share22Tweet14
Previous Post

Progressive Web Application(PWA) 製作

Next Post

處理 Facebook 官方 SDK PHP 版本過時問題

Related Posts

筆記x備忘

使用 Nginx 基本認證保護動態內容。以一個舊網站為例。

最近處理一個舊網站,因為是 demo 用...

2024-10-27
100
筆記x備忘

Mac 使用 Nodejs 的管理工具 n 來切換版本

Nodejs 在前端應用越來越廣泛,有時...

2024-08-19
100
筆記x備忘

Linux 上使用 Monit 做監控

Monit 是一個不錯用的監控軟體,可以...

2023-12-26
100
dense computer vision output log text IDE, font, layout, debug session, black and white, command line
筆記x備忘

開放原始碼防毒軟體 ClamAV

ClamAV 是 Linux 相當知名的...

2024-12-15
100
筆記x備忘

Linode 伺服器調整規格與調整硬碟空間配置

常常會有需要調整 VPS 規格的狀況,一...

2023-10-09
100
筆記x備忘

Linux SSH 斷線後保持 session 的工具 – Screen

紀錄一下之前用很久的一個 linux 套...

2023-10-09
100
Load More
Next Post

處理 Facebook 官方 SDK PHP 版本過時問題

vue3 學習筆記 EP1

vue3 學習筆記 EP2

全站搜尋

No Result
View All Result

關於我

育心文具行

Jerry Lin

程式設計師

育心文具行是一家文具店,老闆的小兒子是一個設計師,職業是設計程式,興趣是設計人,倒是還沒有實作的機會。
--
所有的相遇都不是巧合。
在廣告公司待了三年有兩年多在做內容產品,離職後繼續在內容產業走了四年多,最後選則離開台灣的公司體制在家 SOHO ,碰上了 2020 年疫情才知道原來自己這是走在時代的潮流尖端。 感謝許多老闆和貴人相助,至今目前尚能存活,在台北街頭努力著。

近期文章

  • 於 MacOS 中,整合自然語言,自動化添加行事曆事件
  • 使用 deepwiki-open 針對程式碼產生 WIKI
  • 使用 Tailwind CLI 快速建立靜態 CSS 檔的基本步驟
  • Visual Studio Code 的 PHP CS Fixer 設定
  • MacOS 添加本地伺服器的 DNS

分類

  • 心得x體驗 (45)
  • 筆記x備忘 (77)
  • 閒談x雜記 (13)

贊助買咖啡

Facebook Instagram RSS

標籤

ai android cloudflare flutter git ios javascript linode linux MAC macos mis nginx php plugin QBQ!問題背後的問題 server work sublime sublime text vps vue.js vue3 What if What If? 如果這樣,會怎樣? wordpress 前端 原則 原子習慣 團隊,從傳球開始 團隊,從傳球開始:五百年都難以超越的 UCLA 傳奇教練伍登培養優越人才和團隊的領導心法 壓力測試 外掛 如果這樣,會怎樣?:胡思亂想的搞怪趣問 正經認真的科學妙答 心得 情緒 活動心得 灰階思考 約翰‧漢尼斯 股癌 自慢10 自慢10:18項修練 記錄 謝孟恭 讀書心得 這一生,你想留下什麼?

文章分類

  • 心得x體驗 (45)
  • 筆記x備忘 (77)
  • 閒談x雜記 (13)

近期文章

  • 於 MacOS 中,整合自然語言,自動化添加行事曆事件
  • 使用 deepwiki-open 針對程式碼產生 WIKI
  • 使用 Tailwind CLI 快速建立靜態 CSS 檔的基本步驟
  • Visual Studio Code 的 PHP CS Fixer 設定
  • MacOS 添加本地伺服器的 DNS

近期留言

  • 「Bolin Lai」於〈WordPress 之中藍新金流開啟後, Elementor 外掛有時會打不開的問題處理〉發佈留言
  • 「Jerry Lin」於〈WordPress 之中藍新金流開啟後, Elementor 外掛有時會打不開的問題處理〉發佈留言
  • 「JCL」於〈WordPress 之中藍新金流開啟後, Elementor 外掛有時會打不開的問題處理〉發佈留言

文章月曆

2025 年 6 月
日 一 二 三 四 五 六
1234567
891011121314
15161718192021
22232425262728
2930  
« 5 月    

© 2020 hipster.crazyjerry.studio - a blog about experience, notes and nonsense, by Jerry Lin.

No Result
View All Result
  • 首頁
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 我的工具箱
  • 關於我

© 2020 hipster.crazyjerry.studio - a blog about experience, notes and nonsense, by Jerry Lin.