说明:以下命令都在终端中运行
1、更新源
sudo apt update
2、安装桌面所需的软件包
sudo apt install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal ubuntu-desktop
3、安装 TightVNC 服务器
sudo apt install tightvncserver
4、通过vncserver 命令启动 VNC 服务器
vncserver
5、输入并验证密码以远程访问
OutputYou will require a password to access your desktops.
Password:
Verify:
密码的长度必须介于6~8个字符之间。
验证密码后,可以选择创建仅供查看的密码。使用仅查看密码登录的用户将无法使用鼠标或键盘控制 VNC 实例,如果没有演示需要的输入n即可,后续如有需要可以再设置。
OutputWould you like to enter a view-only password (y/n)?
后续如果想更改密码或添加仅查看密码,可以使用以下命令:
vncpasswd
配置 xstartup 配置文件:
在配置 xstartup 配置文件时,可以使用不同的窗口管理器和桌面环境。本教程使用的是 GNOME Flashback 桌面环境和 metacity 窗口管理器。如果希望使用其他的桌面环境和窗口管理器,需要相应地修改 xstartup 配置文件。
6、备份VNC的xstartup配置文件
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
7、修改VNC的xstartup配置文件
nano ~/.vnc/xstartup
复制以下内容到打开的文件:
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
export XDG_MENU_PREFIX="gnome-flashback-"
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check
8、重新启动 VNC
vncserver -geometry 1920x1080 :1 -localhost no
geometry
选项指定窗口大小,localhost
选项设为 no
以开放连接,1920×1080的“×”本人是用英文字母x代替的。
9、在Windows端远程连接Ubuntu
在Windows上安装VNC远程控制软件,输入Ubuntu中VNC地址。
Windows版VNC自行下载
Ubuntu中VNC地址查询命令:
ifconfig
注:有些处理器自带VNC功能,可能只需在设置里面打开VNC远程共享即可