Connect Remotely Server through VNC Server
Hello and welcome. Practically in enterprise environment in users connects to server/system remotely using clients. Number of remote access tools/utilities are available which we can use to access remote systems/servers from anywhere. VNC is one of popular or I would say most popular utility to provide remote access to users to connect to remote server where vnc server is installed and running. So all this tutorial is to give introduction and do basic VNC server configuration and accessing it via vnc client.
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/[email protected]
. [1]
Introduction
VNC stand for Virtual Network Computing. VNC is a remote display system which give you access to view/provide desktop environment to deal with system related troubleshooting/issues or what do you want. VNC provide client/server model. Multiple clients connect at the same time. VNC uses the Remote Frame Buffer (RFB) protocol.
- The VNC Server shares its screen with the client to take control or work on it.
- The VNC Viewer/Client is program that control or work on the server.
To start configuring VNC server you need to make sure that you have GNOME Desktop install on that system if not then install by using yum command.
Server Side
[root@faraz ~]# yum groupinstall "GNOME Desktop"
For installation of VNC you can use command
[root@faraz ~]# yum install tigervnc-server
After installation we need to copy one file which is VNC service from /lib/system/system/[email protected] to /etc/systemd/system/vncserver@:Id#.service as you can see I added the id number for VNC because by default VNC server listens 5900 port if we create a remote user which accesses system by client/viewer then we have to mention the id of that user in this regard the port change with added the id number for example if you are providing id number is 2 then 5900+2=5902 you can call it sub port.
[root@faraz ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:2.service
Now we need to edit at the end of this file to enter some parameter. By default file in file there is no user defined. It shows like <USER>.
[root@faraz ~]# vi /etc/systemd/system/vncserver@\:2.service [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
You need to enter user name you want to give remote access through this user. Here I am going to add xyz user. This user must exist on system
[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 xyz -c "/usr/bin/vncserver %i" PIDFile=/home/xyz/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target
In CentOS/REHL 7 by default firewall service is in running state you can stop by using command.
[root@faraz ~]# systemctl stop firewalld
If you do not want to stop firewall service then you have to make rule for VNC server connection.
[root@faraz ~]# firewall-cmd --permanent --zone=public --add-port=5902/tcp
[root@faraz ~]# firewall-cmd –reload
If your login shell prompt its means command execute successfully.
Now set the VNC password but you need to switch that user.To set VNC password use command vncserver
[xyz@faraz root]$ vncserver You will require a password to access your desktops. Password: Verify: xauth: file /home/xyz/.Xauthority does not exist New 'faraz.test.server:1 (xyz)' desktop is faraz.test.server:1 Creating default startup script /home/xyz/.vnc/xstartup Starting applications specified in /home/xyz/.vnc/xstartup Log file is /home/xyz/.vnc/faraz.test.server:1.log
As you can see in above command xyz user creates and startup its file. Now reload the system daemon by using command systemctl daemon-reload.
[root@faraz ~]# systemctl daemon-reload
Start the service of vnc server
[root@faraz ~]# systemctl start vncserver@:2.service
You can enable the service at boot time.
[root@faraz ~]# systemctl enable vncserver@:2.service
Client Side
To access the remote server we need to install tiger VNC viewer by using yum command.
[root@faraz ~]# yum install tigervnc
Here on client side I am using CentOS 6.5 . To start GUI Tigervnc Viewer you will need to go to Applications>Internet>Tigervnc viewer.
After entering the IP with id/port number click ok button. Another dialog box will open and will ask for password enter password and hit Enter.
You are able to login to server running vnc server.
You can also use command line. use command vncviewer IP:Id# see below image;
We have successfully done the configuration of VNC server and accessed server by vnc client(VNC Viewer). I hope you enjoyed this tutorial . If you feel trouble/issue in any phase during installation. feel free to get back to us and will try to help in every possible way and don’t forget to subscribe our newsletter for upcoming tutorials.
Thanks
Reference(s) 1. https://access.redhat.com/