VNC installation in rhel7

VNC installation in rhel7

Will see how to install VNC installation in rhel7 in this post.

VNC will help us to share the desktop with GUI and for that in both server VNC Server/client should be installed.

Before installing VNC, we should install GNOME in RHEL7.

Installing VNC Server:

Use yum to install the VNC Server. Before that yum should be configured on your server.

[root@localhost ~]# yum -y install vnc*

Configuring VNC Server in RHEL7:

To configure the port and user, need to copy [email protected] from /lib/systemd/system/ to /etc/systemd/system/.

5900 is default listening port.

[root@localhost ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/

Now open the /etc/systemd/system/[email protected] file using vi editor and locate <USER> replace with your respective username which you are going to use for remote access.

[root@localhost ~]# vi /etc/systemd/system/vncserver\@.service

[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=/usr/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

Updated:

[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=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/home/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

Now enable the port over the firewall to allow VNC access using firewalld.

[root@localhost ~]# firewall-cmd --permanent --add-port=5900/tcp
success
[root@localhost ~]# firewall-cmd --reload
success

Than start VNC server

[root@localhost ~]# vncserver

Now it will prompt to set the password to access the desktop.

You will require a password to access your desktops.
Password:
Verify:
xauth: file /root/.Xauthority does not exist

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

Now reload the systemctl daemon

[root@localhost ~]# systemctl daemon-reload

 

And start and enable the service in this run level permanently using below command.

[root@localhost ~]# systemctl start [email protected]

[root@localhost ~]# systemctl enable [email protected]

Finally, we completed all the configuration on Linux Machine and to check this open VNC on a windows machine and try to access using our Linux machine IP Address and port number

192.168.1.104:5900

and it will prompt for the password, provide de password to access the Linux machine.

Reference: itzgeek

One thought on “VNC installation in rhel7”

  1. Greetings from Ohio! I’m bored to death at work so I decided to check out your site on my iphone during lunch break. I really like the information you present here and can’t wait to take a look when I get home. I’m surprised at how fast your blog loaded on my mobile .. I’m not even using WIFI, just 3G .. Anyhow, good blog!

Leave a Reply

Your email address will not be published. Required fields are marked *