码迷,mamicode.com
首页 > 其他好文 > 详细

Configure VNC Server on CentOS 7 / RHEL 7

时间:2015-03-28 06:38:37      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:configure vnc server on centos 7 / rhel 7

The following simple guide help you to setup the VNC server on RHEL 7/CentOS 7 machines, VNC help to share the desktop with the other machines which has a client installed. VNC server and client are not installed by default, you need to setup the vnc server manually.

Before installing the VNC server, let us install Gnome desktop.

[root@server ~]# yum groupinstall "GNOME Desktop"

Install the tigervnc server and X11 fonts.

[root@server ~]# yum install tigervnc-server xorg-x11-fonts-Type1

Copy the VNC server configuration file to /etc/systemd/system/ for configuring the system service. While copying, you can mention which port it should listen. By default VNC server listens on 5900, but if you setup port-offset for VNC; we can run a service on a sub-port of the default port 5900. For example, if we mention port 5, it will be accessible on 5905.  You can connect the VNC server by specifying ipaddress:sub-port (192.168.2.109:5 or 192.168.2.109:5905)

[root@server ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service

Edit the copied file.

[root@server ~]# vi /etc/systemd/system/vncserver@:5.service

At the end of file, you will find the lines like below.

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :‘[Install]
WantedBy=multi-user.target

Replace <USER> with your real user, in my case i replaced with user called “raj” with the screen size.

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l raj -c “/usr/bin/vncserver %i -geometry 1280×1024″
PIDFile=/home/raj/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :‘[Install]
WantedBy=multi-user.target

Add firewall rules to allow the VNC connection, the following rule is set as per the port-offset mentioned in the previous step.

[root@server ~]# firewall-cmd --permanent --zone=public --add-port=5905/tcp
[root@server ~]# firewall-cmd --reload

Start VNC server after switching to raj.

[raj@server ~]$ vncserver

Set the password.

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /home/raj/.Xauthority does not exist

New ‘localhost.localdomain:1 (raj)’ desktop is server.itzgeek.com:1

Creating default startup script /home/raj/.vnc/xstartup
Starting applications specified in /home/raj/.vnc/xstartup
Log file is /home/raj/.vnc/server.itzgeek.com:1.log

Reload the systemctl daemon as root

systemctl daemon-reload

Start the VNC service as root.

systemctl start vncserver@:5.service

Enable it on system startup as root.

systemctl enable vncserver@:5.service

Take remote desktop.

ipaddress:5905 or ipaddress:5

技术分享

CentOS 7 – VNC Connection

You will be asked to enter the password, enter the password that you have created earlier.

技术分享CentOS 7 – VNC Authendication

Now you will get the vnc desktop session.

技术分享CentOS 7 – VNC Desktop


本文出自 “Permanent” 博客,请务必保留此出处http://ericklee.blog.51cto.com/6941516/1625798

Configure VNC Server on CentOS 7 / RHEL 7

标签:configure vnc server on centos 7 / rhel 7

原文地址:http://ericklee.blog.51cto.com/6941516/1625798

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!