安装桌面服务¶
1、更新源¶
sudo apt-get update
sudo apt-get -y upgrade
2、安装桌面环境¶
我们会为每个用户在显示器上安装轻量级的 XFCE 桌面环境(不推荐像 gdm 这样沉重的显示管理器):
apt-get --yes dist-upgrade && DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y xfce4 xfce4-goodies
3、安装vnc服务器¶
sudo apt-get install -y tightvncserver
4、设置vnc启动固定端口¶
vim /usr/bin/vncserver
#$vncPort = 5900 + $displayNumber;
$vncPort = 5901;
5、运行vnc设置密码¶
vncserver
运行过程案例展示(为了不与他人共享 VNC 会话,因此不创建只读密码):
ubuntu@ip-172-31-28-185:~$ vncserver
You will require a password to access your desktops.
Password:
Warning: password truncated to the length of 8.
Verify:
Would you like to enter a view-only password (y/n)? n
xauth: file /home/ubuntu/.Xauthority does not exist
New 'X' desktop is ip-172-31-28-185:1
Creating default startup script /home/ubuntu/.vnc/xstartup
Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ip-172-31-28-185:1.log
6、更新xstartup文件¶
cd .vnc
cp xstartup xstartup.bak
vim xstartup
#!/bin/sh
#############################
## All ##
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export SHELL=/bin/bash
#############################
## Gnome ##
#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#vncconfig -iconic &
#dbus-launch --exit-with-session gnome-session &
############################
## LXQT ##
####exec openbox-session
#exec startlxqt
############################
## KDE ##
#exec /usr/bin/startkde
############################
## XFCE ##
startxfce4 &
6.1 经过测试 xstartup 文件不能直接使用,需要将最后的 “&” 删掉¶
sed -i "s/startxfce4 &/startxfce4/" ~/.vnc/xstartup
7、重启启动vnc¶
Lsof -i:5901
Kill -9 pid
vncserver -geometry 1920x1080 #-geometry 分辨率
8、连接桌面¶
如果是window 系统: 安装git bash: 参考:https://blog.csdn.net/qq_45281589/article/details/134650456
ssh -CNg -L 5901:127.0.0.1:5901 root@i-1.gpushare.com -p 39490 #返回输入密码
如果是linux 系统 如mac,ubuntu 桌面系统,可以直接在终端输入
ssh -CNg -L 5901:127.0.0.1:5901 root@i-1.gpushare.com -p 39490
8.1 本地安装vnc 客户端¶
举例:window 10 系统 安装vncviewer 客户端(安装略) 参考:https://blog.csdn.net/waicsdn_haha/article/details/143765155 MacOS使用本机屏幕共享功能VNC连接到实例