当前位置: 首页 > 工具软件 > TigerVNC > 使用案例 >

openEuler 22.03 LTS 配置tigervnc使用xfce图形界面

郭元凯
2023-12-01

一 环境准备

# cat /etc/openEuler-release
openEuler release 22.03 LTS

# uname -a
Linux test-aarch64 5.10.0-54.0.0.27.oe1.aarch64 #1 SMP Mon Feb 14 01:47:27 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

# rpm -qa |grep tigervnc-server
tigervnc-server-minimal-1.12.0-2.oe1.aarch64
tigervnc-server-1.12.0-2.oe1.aarch64
tigervnc-server-applet-1.12.0-2.oe1.noarch
tigervnc-server-module-1.12.0-2.oe1.aarch64

二 配置tigervnc-server

修改vncserver-config-defaults , 如果取消localhost ,外部不能访问
 #  vi /etc/tigervnc/vncserver-config-defaults
     
    session=gnome
    securitytypes=vncauth,tlsvnc
    geometry=2000x1200
    # localhost
    alwaysshared

配置vnc用户以及对应的访问端口,:1代表可以通过:1或者5901端口通过root用户进行vnc访问
# vi /etc/tigervnc/vncserver.users
    
    :1=root
    :2=test

登录不同的操作系统用户配置vnc密码
    root用户下的vnc密码
    # vncpasswd
    Password:
    Verify:
    Would you like to enter a view-only password (y/n)? y
    Password:
    Verify:

     
    test用户下的vnc密码
    $ vncpasswd
    Password:
    Verify:
    Would you like to enter a view-only password (y/n)? y
    Password:
    Verify:

配置/root/.vnc/xstartup或者/home/test/.vnc/xstartup

# cat  xstartup

内容如下:

#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
#exec /etc/X11/xinit/xinitrc
(sleep 5 && export DISPLAY=:1 &&  xfce4-session) &

复制vncserver@x.service 文件
对应/etc/tigervnc/vncserver.users文件中的端口信息
#  cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
#  cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
 

配置vnc开机自启服务

#   systemctl enable vncserver@:1
#   systemctl enable vncserver@:2

配置selinux

# getenforce
Disabled

重启服务器

# reboot

启动vnc服务
#   systemctl start vncserver@:1
#   systemctl start vncserver@:2

停止vnc服务

#   systemctl stop vncserver@:1
#   systemctl stop vncserver@:2

查看状态

# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
     Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-02-19 16:15:01 CST; 35min ago
    Process: 902 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
   Main PID: 911 (vncsession)
      Tasks: 0 (limit: 41953)
     Memory: 2.0M
     CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
             ‣ 911 /usr/sbin/vncsession root :1

Feb 19 16:15:00 test-aarch64 systemd[1]: Starting Remote desktop service (VNC)...
Feb 19 16:15:01 test-aarch64 systemd[1]: Started Remote desktop service (VNC).

# systemctl status vncserver@:2.service
● vncserver@:2.service - Remote desktop service (VNC)
     Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-02-19 16:15:01 CST; 35min ago
    Process: 908 ExecStart=/usr/libexec/vncsession-start :2 (code=exited, status=0/SUCCESS)
   Main PID: 919 (vncsession)
      Tasks: 0 (limit: 41953)
     Memory: 688.0K
     CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service
             ‣ 919 /usr/sbin/vncsession test :2

Feb 19 16:15:00 test-aarch64 systemd[1]: Starting Remote desktop service (VNC)...
Feb 19 16:15:01 test-aarch64 systemd[1]: Started Remote desktop service (VNC).
 

# ps -ef |grep vnc
root         911       1  0 16:14 ?        00:00:00 /usr/sbin/vncsession root :1
root         919       1  0 16:14 ?        00:00:00 /usr/sbin/vncsession test :2
test        1013     919  0 16:15 ?        00:00:00 xinit /etc/X11/xinit/Xsession startxfce4 -- /usr/bin/Xvnc :2 -alwaysshared -geometry 2000x1200 -securitytypes vncauth,tlsvnc -auth /home/test/.Xauthority -desktop test-aarch64:2 (test) -fp catalogue:/etc/X11/fontpath.d -pn -rfbauth /home/test/.vnc/passwd -rfbport 5902
root        1030     911  0 16:15 ?        00:00:00 xinit /etc/X11/xinit/Xsession startxfce4 -- /usr/bin/Xvnc :1 -alwaysshared -geometry 2000x1200 -securitytypes vncauth,tlsvnc -auth /root/.Xauthority -desktop test-aarch64:1 (root) -fp catalogue:/etc/X11/fontpath.d -pn -rfbauth /root/.vnc/passwd -rfbport 5901
root        1085    1030  0 16:15 ?        00:00:00 /usr/bin/Xvnc :1 -alwaysshared -geometry 2000x1200 -securitytypes vncauth,tlsvnc -auth /root/.Xauthority -desktop test-aarch64:1 (root) -fp catalogue:/etc/X11/fontpath.d -pn -rfbauth /root/.vnc/passwd -rfbport 5901
test        1088    1013  0 16:15 ?        00:00:00 /usr/bin/Xvnc :2 -alwaysshared -geometry 2000x1200 -securitytypes vncauth,tlsvnc -auth /home/test/.Xauthority -desktop test-aarch64:2 (test) -fp catalogue:/etc/X11/fontpath.d -pn -rfbauth /home/test/.vnc/passwd -rfbport 5902
root        2263    2203  0 16:16 pts/0    00:00:00 grep --color=auto vnc

三 验证

vncviewer ip:1  root用户vnc访问

vncviewer ip:2  test用户vnc访问

 类似资料: