Social icon element need JNews Essential plugin to be activated.
星期日, 2 4 月, 2023
No Result
View All Result
育心文具行

育心文具行

  • 首頁
  • 創作x紀錄
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 當紅俱樂部
  • 留言給我
育心文具行
  • 首頁
  • 創作x紀錄
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 當紅俱樂部
  • 留言給我
No Result
View All Result
育心文具行
Home 心得x體驗

製作 Ubuntu 遠端桌面伺服器

2022-09-10
in 心得x體驗, 筆記x備忘
Reading Time: 3 mins read
Share on FacebookShare on Twitter

有時我們會需要安裝一個雲端的伺服器是有 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
Share22Tweet14Share6
Previous Post

Progressive Web Application(PWA) 製作

Next Post

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

Next Post

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

vue3 學習筆記 EP1

vue3 學習筆記 EP2

發佈留言 取消回覆

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

這個網站採用 Google reCAPTCHA 保護機制,這項服務遵循 Google 隱私權政策及服務條款。

全站搜尋

No Result
View All Result

近期文章

  • PHP Codeigniter 4 框架速度優化
  • 《自慢10:18項修練》第四部讀書心得
  • 網頁製作,外包要注意的事情
  • 《自慢10:18項修練》第三部讀書心得
  • 在 Mac 上,大型 CSV 檔案切割方法

分類

  • 創作x紀錄 (12)
  • 心得x體驗 (32)
  • 筆記x備忘 (26)
  • 閒談x雜記 (4)

贊助買咖啡

Social icon element need JNews Essential plugin to be activated.

標籤

22.04 android centos Channel Access Token composer dart dev dist f facebook flutter gist git git hook gitignore highlight hook ios line linode linux MAC php php7.3 php8 QBQ!問題背後的問題 sdk sublime sublime3 ubuntu vps vue vue.js vue3 wordpress 團隊,從傳球開始 團隊,從傳球開始:五百年都難以超越的 UCLA 傳奇教練伍登培養優越人才和團隊的領導心法 意志力 權限 自慢10 自慢10:18項修練 規格 調整硬碟空間 調整規格 讀書心得

文章分類

  • 創作x紀錄 (12)
  • 心得x體驗 (32)
  • 筆記x備忘 (26)
  • 閒談x雜記 (4)

近期文章

  • PHP Codeigniter 4 框架速度優化
  • 《自慢10:18項修練》第四部讀書心得
  • 網頁製作,外包要注意的事情
  • 《自慢10:18項修練》第三部讀書心得
  • 在 Mac 上,大型 CSV 檔案切割方法

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

No Result
View All Result
  • 首頁
  • 創作x紀錄
  • 心得x體驗
  • 筆記x備忘
  • 閒談x雜記
  • 當紅俱樂部
  • 留言給我

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