目录 

   0. 环境信息和说明

  1. Ubuntu 18.04上安装xrdp远程ubuntu-desktop桌面服务
  2. Ubuntu 18.04上安装xrdp远程Xfce桌面服务
  3. Ubuntu 18.04上安装vnc远程Xfce桌面服务

0.环境信息和说明

-----------

Ubuntu版本

# cat /etc/os-releaseNAME="Ubuntu"VERSION="18.04.3 LTS (Bionic Beaver)"ID=ubuntuID_LIKE=debianPRETTY_NAME="Ubuntu 18.04.3 LTS"VERSION_ID="18.04"

Windows版本

>winver

乌班图Unity界面_ubuntu 启动图形界面命令

1. Ubuntu 18.04上安装xrdp远程ubuntu-desktop桌面服务

---------

1.1 安装桌面

# sudo apt update# sudo apt-get install ubuntu-desktop -y

注:apt update更新可用包的列表,安装ubuntu-desktop桌面,安装大概15-30分钟,具体由网络情况决定。

安装完成后,登录console,切换到图形界面

# systemctl set-default graphical.target # systemctl isolate graphical.target

ubuntu-desktop图形界面如下:

乌班图Unity界面_ubuntu 远程 windows_02

---------

1.2 安装 Xrdp

输入以下命令:

# sudo apt-get install xrdp -y

通过xrdp可以ubuntu桌面

---------

1.3 安装dconf-editor

需要取消掉请求加密的功能,否则缺少这一步是无法远程上的,需要安装dconf-editor工具进行配置,输入以下命令:

# sudo apt-get install dconf-editor -y

桌面修改:搜索 dconf-editor   org/gnome/desktop/remote-access/requre-encryption  设置为OFF,默认ON

乌班图Unity界面_ubuntu安装图形界面_03

乌班图Unity界面_vue vnc远程登录_04

乌班图Unity界面_ubuntu 远程 windows_05

乌班图Unity界面_vue vnc远程登录_06

乌班图Unity界面_ubuntu 启动图形界面命令_07


2.  Ubuntu 18.04上安装xrdp远程Xfce桌面服务

---------

2.1 安装桌面环境

Ubuntu 存储库中有几个桌面环境 (DE) 。安装 Xfce,它是一个快速,稳定和轻量级的桌面环境,非常适合在远程服务器上使用。

以具有 sudo 权限的用户身份键入以下命令,以在服务器上安装 Xfce :

# sudo apt update# sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils -y

---------

2.2 安装 Xrdp

Xrdp 包在默认的 Ubuntu 存储库中可用。要安装它,请运行:

# sudo apt install xrdp  -y

安装过程完成后, Xrdp 服务将自动启动。您可以通过键入以下内容来验证 Xrdp 是否正在运行:

# sudo systemctl status xrdp

---------

2.3 配置 Xrdp

Xrdp 配置文件位于 /etc/xrdp 目录中。对于基本的 Xrdp 连接,只需要配置 Xrdp 即可使用 Xfce 。

修改配置文件 /etc/xrdp/xrdp.ini

# sudo vim /etc/xrdp/xrdp.iniexec startxfce4   ##在文件末尾添加

保存文件并重新启动 Xrdp 服务:

# sudo systemctl restart xrdp

---------

2.4 登录验证

乌班图Unity界面_ubuntu 远程 windows_08

乌班图Unity界面_ubuntu安装图形界面_09

乌班图Unity界面_ubuntu安装图形界面_10


3. Ubuntu 18.04上安装vnc远程Xfce桌面服务

---------

3.1 安装桌面环境

大多数服务器没有安装桌面环境,因此我们首先要安装轻量级桌面环境。

安装 Xfce 是快速、稳定和轻量级的桌面环境,非常适合在远程服务器上使用。

# sudo apt update# sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils -y

---------

3.2 windows客户端

Windows 10 安装VNC-Viewer,vnc可以访问ubuntu桌面

下载链接:

VNC-Viewer-6.18.907-Windows.exe

链接:https://pan.baidu.com/s/1tzwg1CAGeEMczBMlCbagAQ

提取码:1v4a

---------

3.3 .安装VNC服务器

Ubuntu 存储库中还有几种不同的 VNC 服务器,如 TightVNC , TigerVNC 和 x11vnc 。每个 VNC 服务器在速度和安全性方面都有不同的优点和缺点。

安装 TigerVNC ,它是高性能 VNC 服务器。

# sudo apt install tigervnc-standalone-server tigervnc-common -y

现在安装了 VNC 服务器,下一步是运行 vncserver 命令,该命令将创建初始配置并设置密码。

运行以下命令时不要使用 sudo :

#  sudo vncserverYou will require a password to access your desktops.Password:Verify:Would you like to enter a view-only password (y/n)? n/usr/bin/xauth:  file /root/.Xauthority does not existNew 'test-lu-u18-03:1 (root)' desktop at :1 on machine test-lu-u18-03Starting applications specified in /etc/X11/Xvnc-sessionLog file is /root/.vnc/test-lu-u18-03:1.logUse xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :1 to connect to the VNC server.

注: ~/.vnc/passwd  存放密码   /home/appuser/.vnc/test-lu-u18-02:1.log 查看日志,重要的是要记住,当使用 VNC 服务器时, :X 是一个引用的显示端口 5900+X 。

# sudo vncserver -kill :1   ##关闭vncserver

---------

3.4 配置 VNC 服务器

已经在服务器上安装了 Xfce 和 TigerVNC ,需要配置 TigerVNC 来使用 Xfce 。需要创建以下文件 〜/.vnc/xstartup

在非root用户操作

# vim ~/.vnc/xstartup#!/bin/shunset SESSION_MANAGERunset DBUS_SESSION_BUS_ADDRESSexec startxfce4

保存并关闭文件。无论何时启动或重启 TigerVNC 服务器,都将自动执行上述命令。

~/.vnc/xstartup 文件还需要具有执行权限。运行以下命令以确保权限正确:

# sudo chmod u+x ~/.vnc/xstartup

如果需要将附加选项传递给 VNC 服务器,则可以创建一个名为 config 的文件,并为每行添加一个选项:

# vim ~/.vnc/configgeometry=1920x1084dpi=96

---------

3.5 创建 Systemd 单元文件

创建服务

# sudo vim /etc/systemd/system/vncserver@.service[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]Type=simpleUser=appuserPAMName=loginPIDFile=/home/%u/.vnc/%H%i.pidExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'ExecStart=/usr/bin/vncserver :%i -geometry 1440x900 -alwaysshared -localhost no -fgExecStop=/usr/bin/vncserver -kill :%i[Install]WantedBy=multi-user.target

启动服务

# sudo systemctl daemon-reload# sudo systemctl enable vncserver@1.service# sudo systemctl start vncserver@1.service# sudo systemctl status vncserver@1.service

乌班图Unity界面_ubuntu 远程 windows_11

---------

3.6 登录验证

乌班图Unity界面_ubuntu 启动图形界面命令_12

乌班图Unity界面_vue vnc远程登录_13

乌班图Unity界面_ubuntu安装图形界面_14

乌班图Unity界面_ubuntu 远程 windows_15