0%

Ubuntu20.04 安装 xrdp 桌面远程服务

# xrdp是原生方案,兼容性是最好的,也不需要太多额外的软件支持。
sudo apt install xrdp
sudo systemctl enable xrdp

# 改配置第49行,new_cursors=true改为false
sudo sed -e 's/^new_cursors=true/new_cursors=false/g' -i /etc/xrdp/xrdp.ini
sudo systemctl restart xrdp
         
# 创建 ~/.xsessionrc
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop
tee ~/.xsessionrc <<'EOF'
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export XDG_DATA_DIRS=${XDG_DATA_DIRS}
export XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
EOF

# 配置 polkit
sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla <<-'EOF'
[Netowrkmanager]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF
sudo systemctl restart polkit

# 配置防火墙
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw allow 3389/tcp

注意Ubuntu同时只能被一个用户桌面连接,包括机器本身!