server端安装如下包:
yum groupinstall "GNOME Desktop" "Graphical Administration Tools"
yum groupinstall "X Window System"
yum -y install tigervnc-server
yum install vnc
客户机安装vncClient:
https://www.realvnc.com/en/connect/download/viewer/
vncserver 启动后设置文件: sed -i 's/twm/gnome-session/g' /root/.vnc/xstartup
安装完成后以root身份启动vncserver:
vncserver
首次启动vncserver , 需要创建管理员密码
输入两次管理员密码, 简单方便即可;
执行: sed -i 's/twm/gnome-session/g' /root/.vnc/xstartup
重启vncserver
启动后, 服务端会自动创建用户:
New ‘localhost:1 (root)’ desktop is localhost:1
Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log
export DISPLAY=localhost:1
执行xhost
access control disabled, clients can connect from any host
临时关闭防火墙
iptables -I INPUT -p tcp --dport 5901 -j ACCEPT
真机启动vncclient:
vncclient里输入 vncserver-IP:1
输入ip : 5901 --- >> IP:5900 1 --- >> 1表示vncserver 创建的第一个用户, 1xx.1xx.xx.xx: 5901 ---- >> 第三个: 1xx.1xx.xx.xx: 5903
输入完成后点击ok, 选中客户机右键,connect,进入vnc桌面