Configuring VNC Server for GUI remote access
VNC or Virtual Network Computing is graphical desktop sharing tool. VNC server provides a duplicate of server display for the clients attached to it. A number of clients can be connected to using VNC.
In RHEL/CentOS 7, we use a package named “tigervnc-server” to setup VNC server. We will now start with installation but before we do that make sure that we have graphical version of OS installed. If that’s not the case, we will first install the graphical desktop,
$ yum groupinstall “GNOME Desktop”
If you already have graphical packages installed, skip this step & move onto installation of VNC-server.
Installation
We can install vnc server using the yum,
$ yum install tigervnc-server xorg-x11-fonts-Type1
Once the required packages have been installed, we will move to configuration part,
Configuration
Configuration file for VNC is /lib/systemd/system/vncserver@.service. We need to copy /lib/systemd/system/vncserver@.service to /etc/systemd/system/vncserver@:1.service, where :1 is used to denote port number 5901 . We can also assign it different port number like :2 or :3 (for 5902, 5903).
$ cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Next, we will add user information in the configuration file. So we will add a user named ‘vncuser’ for accessing vnc
$ useradd vncuser
Now open /etc/systemd/system/vncserver@:1.service, & add user information (see screenshot)
$ vi /etc/systemd/system/vncserver@:1.service
Next, we will assign a password to access the VNC server,
$ su vncviewer
$ vncserver
$ vncserver
You will be asked to enter a password & then confirm it & some files will be created after that.
Our VNC server is now ready to be used, we will restart service & enable it , so it can restart on every reboot,
$ systemctl daemon-reload
$ systemctl start vncserver@:1.service
$ systemctl enable vncserver@:1.service
$ systemctl start vncserver@:1.service
$ systemctl enable vncserver@:1.service
Note:- If you are getting an error while starting vnc service, reboot your system & try starting service then.
Testing the server
To test the vnc server, we require VNC-viewer to installed on the testing machine. I am using a Windows 10 machine with vnc-viewer installed.
Open vnc –viewer & enter the server address with port number
Next, you will get a warning if you are using an unencrypted connection, press “continue”
You will now be asked VNC password, enter the password to connect the session & you can see the display of the server.
If you want to add more user, repeat the whole process but change the port number from /etc/systemd/system/vncserver@:1.service to /etc/systemd/system/vncserver@:2.service or /etc/systemd/system/vncserver@:3.service & so on.
No comments:
Post a Comment