Vnc Server on a CentOS/RHEL 7 system

I’m currently running a server gui on a RHEL7 Server, which is working fine if you want to work directly from the console.  However if the server is in a very awkward place, like it is in my case, you’ll probably want to remote control the server from the safety and warmth of your man/woman-cave.  Here’s the steps I took to install VNC Server on my RHEL machine.

Install the software

yum install tigervnc-server xorg-x11-fonts-Type1

Copy the server config file

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service

Edit the file

vi /etc/systemd/system/vncserver@:5.service

Look for this text in the file

[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 the ‘USER’ text, with your actual username

Add firewall rules to allow your VNC connection

firewall-cmd --permanent --zone=public --add-port=5905/tcp
firewall-cmd --reload

As the user run vncserver

vncserver

Set your password

Reload the systemctl daemon as root

systemctl daemon-reload

Start the VNC service as root

systemctl start vncserver@:5.service

Enable it as a system startup service

systemctl enable vncserver@:5.service

Connect to the server using tightvnc view [for example]

xxx.xxx.xxx.xxx:5

Enjoy your server desktop.

Advertisements

One thought on “Vnc Server on a CentOS/RHEL 7 system

  1. If you don’t mind using the EPEL repository (assuming EL6 or EL7 and not EL5) you should really consider using x2go rather than VNC. x2go has several benefits: 1) It is way faster, 2) it works over ssh which you probably are already using, 3) since it works over ssh its encrypted (does VNC do encryption by default these days or is it still a bit of manual labor?), 4) It can do additional things like filesharing (I haven’t tried it), printing (I haven’t tried it) and sound (use it frequently).

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s