tigervnc-server配置

  • 安装服务端

yum install tigervnc tigervnc-server
# 安装openbox窗口管理器
yum install openbox

# 非必须
        vi /etc/sysconfig/vncservers

        VNCSERVERS="1:root 2:user1"
        VNCSERVERARGS[1]="-geometry 1280x1024 -nolisten tcp"
        VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp"

# 启动并输入密码, :1就是5901
vncserver :1
# 提示,需要设置密码
# VNC authentication enabled, but no password file created.
vncpasswd
# 查看已经启动的
vncserver -list
vncserver -kill :1

# 把启动图形的命令 放进去
vi ~/.vnc/xstartup

exec openbox-session
  • ~/.vnc/xstartup 原文

#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
# Assume either Gnome or KDE will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
    vncserver -kill $DISPLAY
fi

exec openbox-session
  • 连接

# 下载 vncviewer64-1.12.0.exe https://sourceforge.net/projects/tigervnc/files/stable/1.12.0/

# 直接连接
172.21.177.49:5901

# 就会进入openbox的桌面


# 安装一个terminal,不然图形界面无法操作
yum install xterm
  • 其他

# 通常使用:2,5902端口,不使用:1,5901端口
vncserver :2

ls /tmp/.X11-unix/X2

# 指定显示的DISPLAY
export DISPLAY=:2.0
  • libvirt kvm 配置 vnc

# 打开xml编辑允许状态
# 然后打开虚拟机进行编辑xml文件, 或者增加[图形][vnc]
<graphics type="spice" autoport="yes">
    <listen type="address"/>
    <image compression="off"/>
</graphics>
# 修改为
<graphics type='vnc' port='5990' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
</graphics>

# 重启该虚拟机, 查看宿主机端口, 还可以指定graphics 的 passwd 参数
sudo netstat -lntp | grep 5990

# 客户端就可以直接连接了,没有密码
# 使用Remmina客户端连接内网 [ip]:5990

# 启动虚拟机提示 does not support machine type 'pc-q35-7.0'
# 查看支持模拟的身设备
qemu-kvm -machine help