Configure VNC Server on CentOS 7 / RHEL 7

來源:互聯網
上載者:User

標籤: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.

[[email protected] ~]# yum groupinstall "GNOME Desktop"

Install the tigervnc server and X11 fonts.

[[email protected] ~]# 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)

[[email protected] ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:5.service

Edit the copied file.

[[email protected] ~]# vi /etc/systemd/system/[email protected]: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.

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=5905/tcp[[email protected] ~]# firewall-cmd --reload

Start VNC server after switching to raj.

[[email protected] ~]$ 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 [email protected]:5.service

Enable it on system startup as root.

systemctl enable [email protected]:5.service

Take remote desktop.

ipaddress:5905 or ipaddress:5

650) this.width=650;" src="http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-connection.jpg" alt="CentOS 7 - VNC Connection" width="421" height="212" style="margin:0px 0px 5px;padding:0px;border:0px;vertical-align:baseline;height:auto;background-position:0px 50%;" />

CentOS 7 – VNC Connection

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

650) this.width=650;" class="size-full wp-image-7209" src="http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Authendication.jpg" alt="CentOS 7 - VNC Authendication" width="418" height="215" style="margin:0px 0px 5px;padding:0px;border:0px;vertical-align:baseline;height:auto;background-position:0px 50%;" />CentOS 7 – VNC Authendication

Now you will get the vnc desktop session.

650) this.width=650;" class="wp-image-7214" src="http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Desktop.jpg" alt="CentOS 7 - VNC Desktop" width="640" height="440" style="margin:0px 0px 5px;padding:0px;border:0px;vertical-align:baseline;height:auto;background-position:0px 50%;" />CentOS 7 – VNC Desktop


本文出自 “Permanent” 部落格,請務必保留此出處http://ericklee.blog.51cto.com/6941516/1625798

Configure VNC Server on CentOS 7 / RHEL 7

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.