博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Configure VNC in RHEL 7
阅读量:6590 次
发布时间:2019-06-24

本文共 5221 字,大约阅读时间需要 17 分钟。

实验环境: 在RHEL 7.5 中模拟给两个用户 jerry、tom 配置vnc

Note

Unlike in previous Red Hat Enterprise Linux distributions, TigerVNC in Red Hat Enterprise Linux 7 uses the systemd system management daemon for its configuration. The /etc/sysconfig/vncserver configuration file has been replaced by /etc/systemd/system/vncserver@.service.

Installing VNC Server

To install the TigerVNC server, issue the following command as root

[root@vm-server ~]# yum install tigervnc-server

Configuring VNC Server

The VNC server can be configured to start a display for one or more users, provided that accounts for the users exist on the system, with optional parameters such as for display settings, network address and port, and security settings.

  1. A configuration file named /etc/systemd/system/vncserver@.service is required. To create this file, copy the /usr/lib/systemd/system/vncserver@.service file as root:

    [root@vm-server ~]# cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-jerry@.service[root@vm-server ~]# cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-tom@.service
  2. Edit /etc/systemd/system/vncserver-USER@.service, replacing USER with the actual user name. Leave the remaining lines of the file unmodified. The -geometry argument specifies the size of the VNC desktop to be created; by default, it is set to 1024x768.

    34 [Unit] 35 Description=Remote desktop service (VNC) 36 After=syslog.target network.target 37  38 [Service] 39 Type=forking 40  41 # Clean any existing files in /tmp/.X11-unix environment 42 ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' 43 ExecStart=/usr/sbin/runuser -l jerry -c "/usr/bin/vncserver %i -geometry 1366x768" 44 PIDFile=/home/jerry/.vnc/%H%i.pid 45 ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' 46  47 [Install] 48 WantedBy=multi-user.target
  3. Save the changes.
  4. To make the changes take effect immediately, issue the following command:

    [root@vm-server ~]# systemctl daemon-reload
  5. Set the password for the user or users defined in the configuration file. Note that you need to switch from root to USER first.

    [root@vm-server ~]# su - jerry[jerry@vm-server ~]$ vncpasswd Password:Verify:Would you like to enter a view-only password (y/n)? nA view-only password is not used[jerry@vm-server ~]$ exitlogout[root@vm-server ~]# su - tom[tom@vm-server ~]$ vncpasswd Password:Verify:Would you like to enter a view-only password (y/n)? nA view-only password is not used[tom@vm-server ~]$ exitlogout[root@vm-server ~]#

    Important

    The stored password is not encrypted; anyone who has access to the password file can find the plain-text password.

Starting VNC Server

To start or enable the service, execute the following command:

[root@vm-server ~]# systemctl start vncserver-jerry@:1[root@vm-server ~]# systemctl start vncserver-tom@:2

You can also enable the service to start automatically at system start. Then, when you log in, vncserver is automatically started. As root, issue a command as follows:

[root@vm-server ~]# systemctl enable vncserver-jerry@:1Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver-jerry@:1.service to /etc/systemd/system/vncserver-jerry@.service.[root@vm-server ~]# systemctl enable vncserver-tom@:2Created symlink from /etc/systemd/system/multi-user.target.wants/vncserver-tom@:2.service to /etc/systemd/system/vncserver-tom@.service.[root@vm-server ~]#

检查服务状态

[root@vm-server ~]# systemctl status vncserver-jerry@\:1.service ● vncserver-jerry@:1.service - Remote desktop service (VNC)   Loaded: loaded (/etc/systemd/system/vncserver-jerry@.service; enabled; vendor preset: disabled)   Active: active (running) since Sun 2018-09-09 13:22:11 CST; 18min ago Main PID: 6971 (Xvnc)   CGroup: /system.slice/system-vncserver\x2djerry.slice/vncserver-jerry@:1.service           ‣ 6971 /usr/bin/Xvnc :1 -auth /home/jerry/.Xauthority -desktop vm-server:1 (jerry) -fp catalogue:/etc/X11/fontpath.d -geometry 1366x768 ...Sep 09 13:22:08 vm-server systemd[1]: Starting Remote desktop service (VNC)...Sep 09 13:22:11 vm-server systemd[1]: Started Remote desktop service (VNC).[root@vm-server ~]# systemctl status vncserver-tom@\:2.service ● vncserver-tom@:2.service - Remote desktop service (VNC)   Loaded: loaded (/etc/systemd/system/vncserver-tom@.service; enabled; vendor preset: disabled)   Active: active (running) since Sun 2018-09-09 13:22:29 CST; 18min ago Main PID: 7598 (Xvnc)   CGroup: /system.slice/system-vncserver\x2dtom.slice/vncserver-tom@:2.service           ‣ 7598 /usr/bin/Xvnc :2 -auth /home/tom/.Xauthority -desktop vm-server:2 (tom) -fp catalogue:/etc/X11/fontpath.d -geometry 1366x768 -pn ...Sep 09 13:22:25 vm-server systemd[1]: Starting Remote desktop service (VNC)...Sep 09 13:22:29 vm-server systemd[1]: Started Remote desktop service (VNC).[root@vm-server ~]#

At this point, other users are able to use a VNC viewer program to connect to the VNC server using the display number and password defined. Provided a graphical desktop is installed, an instance of that desktop will be displayed. It will not be the same instance as that currently displayed on the target machine.

参考:

测试

jerry vnc接入

图片描述

tom vnc接入

图片描述

后记:

vnc肯定不止这么一点,还有好多要学。
这东西很占资源,1个G的内存
图片描述

转载地址:http://krkio.baihongyu.com/

你可能感兴趣的文章
Android Content Provider的启动过程源码分析
查看>>
POJ1274 The Perfect Stall【二部图最大匹配】
查看>>
极速理解设计模式系列:15.中介者模式(Mediator Pattern)
查看>>
Netty 实现HTTP文件服务器
查看>>
【MFC两种视频图像採集方法】DirectShow与Opencv
查看>>
ORACLE数据库表解锁record is locked by another user
查看>>
MapGuide应用最佳实践--采用托管(Managed)资源还是非托管(Unmanaged)资源
查看>>
iOS:扩展UIColor,支持十六进制颜色设置
查看>>
MapGuide开发中使用Fusion Viewer及通过程序开关图层
查看>>
最简单的基于FFmpeg的AVDevice例子(读取摄像头)【转】
查看>>
解决eclipse不识别Android手机的问题
查看>>
标准答案-有多少人能分得清值类型和引用类型?
查看>>
Java8-Stream-No.12
查看>>
Java编译那些事儿【转】
查看>>
各种排序算法的总结
查看>>
[.net 面向对象程序设计进阶] (25) 团队开发利器(四)分布式版本控制系统Git——使用GitStack+TortoiseGit 图形界面搭建Git环境【转】...
查看>>
SpringBoot相关
查看>>
[LeetCode] Sudoku Solver 求解数独
查看>>
html5/haXe开发偶感
查看>>
js深入研究之神奇的匿名函数类生成方式
查看>>