Tips on how to Set up and Configure VNC on CentOS 7

On this tutorial, we’ll stroll you thru the steps for putting in and configuring a VNC server on a CentOS 7 system. We can even present you learn how to securely connect with the VNC server by an SSH tunnel.

Digital Community Computing (VNC) is a graphical desktop sharing system that means that you can use your keyboard and mouse to remotely management one other pc.


Earlier than persevering with with the tutorial, ensure you are logged in as a person with sudo privileges. We’ll assume you’re logged in as a person named linuxize.

Putting in Xfce Desktop Atmosphere

CentOS server installations typically don’t include a desktop atmosphere put in, so we’ll begin by putting in a light-weight desktop atmosphere.

On this information we’ll be putting in Xfce. It’s a quick, secure and low on system sources, which makes it ultimate for utilization on distant servers.

Xfce packages can be found within the EPEL repositories. In case you don’t have EPEL repository enabled in your server you are able to do it by typing:

sudo yum set up epel-release

As soon as the repository is added, set up Xfce in your CentOS with:

sudo yum groupinstall xfce

Relying in your system, downloading and putting in the Xfce packages and dependencies could take a while.

Putting in VNC Server

We’ll be utilizing TigerVNC as our VNC server of alternative. TigerVNC is an actively maintained high-performance open-source VNC server.

Sort the next command to put in TigerVNC in your CentOS server:

yum set up tigervnc-server

Now that the VNC server is put in the following step is to run the vncserver command which is able to create the preliminary configuration and arrange the password. Don’t use sudo when operating the next command:

You’ll be prompted to enter and make sure the password and whether or not to set it as a view-only password. In case you select to arrange a view-only password the person won’t be able to work together with the VNC occasion with the mouse and the keyboard.

You’ll require a password to entry your desktops.

Would you wish to enter a view-only password (y/n)? n
/usr/bin/xauth: file /house/linuxize/.Xauthority doesn’t exist

New ‘ (linuxize)’ desktop at :1 on machine

Beginning purposes laid out in /and many others/X11/Xvnc-session
Log file is /house/linuxize/.vnc/

The primary time the vncserver command is run, it can create and retailer the password file within the ~/.vnc listing which might be created if not current.

Be aware the :1 after the hostname within the output above. This means the show port quantity on which the vnc server is operating. In our case, the server is operating on TCP port 5901 (5900+1). In case you create a second occasion with vncserver it can run on the following free port i.e :2 that signifies that the server is operating on port 5902 (5900+2).

What’s necessary to recollect is that when working with VNC servers, :X is a show port that refers to 5900+X.

Earlier than persevering with with the following step, first cease the VNC occasion utilizing the vncserver command with a -kill possibility and the server quantity as an argument. In our case the server is operating in port 5901 (:1), so we’ll cease it with:

Killing Xvnc course of ID 2432

Configuring VNC Server

Now that each Xfce and TigerVNC are put in on our CentOS server the following step is to configure TigerVNC to make use of Xfce. To take action open the next file:

And alter the final line from exec /and many others/X11/xinit/xinitrc to exec startxfce4:


exec startxfce4

Save and shut the file. The script above might be mechanically executed everytime you begin or restart the TigerVNC server.

If it’s worthwhile to cross addition choices to the VNC server you’ll be able to open the ~/.vnc/config file and add one possibility per line. The commonest choices are listed within the file. Uncomment and modify to your liking.

Right here is an instance:


# securitytypes=vncauth,tlsvnc
# desktop=sandbox
# localhost
# alwaysshared

Making a Systemd unit file

We’ll create a systemd unit file which is able to allow us to simply begin, cease, and restart the VNC service as wanted, identical as another systemd service.

Copy the vncserver unit file with the cp command:

Open the file along with your textual content editor and change <USER> along with your precise username.

Description=Distant desktop service (VNC)
After=syslog.goal community.goal


# Clear any current recordsdata in /tmp/.X11-unix atmosphere
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/usr/sbin/runuser -l linuxize -c “/usr/bin/vncserver %i”
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’


Save and shut the file. Notify systemd that we created a brand new unit file with:

sudo systemctl daemon-reload

The following step is to allow the unit file with the next command:

The #1 after the @ signal defines the show port on which the VNC service will run, in our case that’s the default 1 and VNC server will hear on port 5901 as we mentioned within the earlier part.

Begin the VNC service by executing:

Confirm that the service is efficiently began with:

[email protected]:1.service – Distant desktop service (VNC)
Loaded: loaded (/and many others/systemd/system/[email protected]:1.service; enabled; vendor preset: disabled)
Lively: lively (operating) since Solar 2018-09-16 09:59:53 UTC; 4s in the past
Course of: 6391 ExecStart=/usr/sbin/runuser -l linuxize -c /usr/bin/vncserver %i (code=exited, standing=0/SUCCESS)
Course of: 6389 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, standing=0/SUCCESS)
Primary PID: 6413 (Xvnc)
CGroup: /system.slice/system-vncserver.slice/[email protected]:1.service
‣ 6413 /usr/bin/Xvnc :1 -auth /house/linuxize/.Xauthority -desktop (linuxize) -fp catalogue:/and many others/X11/fontpath.d -geometry 1024×768 -pn -rfbauth /house/linuxize/.vnc/passwd -rfbport …

Connecting to VNC server

VNC just isn’t an encrypted protocol and might be topic to packet sniffing. The beneficial method is to create an SSH tunnel that may securely forwards site visitors out of your native machine on port 5901 to the server on the identical port.

Set Up SSH Tunneling on Linux and macOS

In case you run Linux, macOS or another Unix-based working system in your machine, you’ll be able to simply create an SSH tunnel with the next command:

ssh -L 5901: -N -f -l username server_ip_address

You’ll be prompted to enter the person password.

Don’t forget to interchange username and server_ip_address along with your username and the IP deal with of your server.

Set Up SSH Tunneling on Home windows

In case you run Home windows, you’ll be able to arrange SSH Tunneling utilizing the PuTTY SSH shopper.

Open Putty and enter your server IP Handle within the Host identify or IP deal with subject.

Below the Connection menu, broaden SSH and choose Tunnels. Enter the VNC server port (5901) within the Supply Port subject and enter server_ip_address:5901 within the Vacation spot subject and click on on the Add button as proven within the picture beneath:

Return to the Session web page to save lots of the settings in order that you don’t want to enter them every time. Now all it’s worthwhile to do is to pick out the saved session and login to the distant server by clicking on the Open button.

Connecting utilizing Vncviewer

Now that you just setup SSH tunneling it’s time to open your Vncviewer and to connect with the VNC Server at localhost:5901.

You should utilize any VNC viewer similar to TigerVNC, TightVNC, RealVNC, UltraVNC Vinagre and VNC Viewer for Google Chrome.

On this instance we’ll be utilizing TigerVNC. Open your VNC viewer, enter localhost:5901 and click on on the Join button.

Enter your password when prompted and it’s best to see the default Xfce desktop. It ought to look one thing like this:

Now you can begin interacting with the distant XFCE desktop out of your native machine utilizing your keyboard and mouse.


By now it’s best to have a VNC server up and operating and you’ll simply handle your CentOS 7 server utilizing a graphic interface.

To configure your VNC server to start out a show for a couple of person, create the preliminary configuration and arrange the password utilizing the vncserver command and create a brand new service file utilizing a unique port.

Be happy to go away a remark when you have any questions.


Germany Devoted Server

Leave a Reply