Ubuntu Desktop 18.04默认提供了远程桌面共享,但是桌面共享使用的是同一个桌面,而且远程桌面共享Gnome极其消耗网络带宽,基本上远程访问的情况下无法流畅使用,因此需要使用单独配置VNC服务。
对于远程桌面而言,xfce4 足够轻量级,占用带宽少,响应速度够快,因此选择使用xfce4作为远程桌面。
安装 vnc4server,xfce4
$ sudo apt install vnc4server xfce4 xfce4-goodies
安装完成后配置VNC登录密码
$ vncpasswd
启动VNC server
$ vncserver
会启动:1 session,同时默认创建了VNC xstartup配置文件
kill掉启动的session,来配置xstartup
$ vncserver -kill :1
打开 ~/.vnc/xstartup 修改配置信息
#!/bin/sh
#Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
重新启动VNC server
$ vncserver
这时候便可以通过VNC Viewer进行访问
:5901
过程中可能会因为防火墙配置无法使用5901端口
$ sudo ufw allow from any to any port 5901 proto tcp
为了更方便的使用VNC服务可以创建文件/etc/systemd/system/vncserver@.service
[Unit]
Deion=Systemd VNC server start