Digital Marketing

How to Setup VNC Server (Linux Remote Desktop Access) on CentOS/RHEL 7 and Fedora

See also:
How to Install xrdp on CentOS 7 / RHEL 7

Install vnc package:
sudo dnf -y install tigervnc-server

Add user: ( or just use existing linux user)
sudo useradd
Set VNC password for that user

sudo cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
(1 is the display number, you can setup 2, 3 ...)

sudo cat /lib/systemd/system/vncserver@\:1.service

Description=Remote desktop service (VNC)

# 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"
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'


sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1.service
sudo systemctl start vncserver@:1.service

Check the server is listening on the port: 590D (D is the display number corresponding to the one you set up )
$ sudo ss -na | grep 590
u_seq  LISTEN     0      128    /run/udev/control 15907                 * 0    
tcp    LISTEN     0      5                      *:5900                  *:*     
tcp    LISTEN     0      5                     :::5900                 :::*     

Make sure your firewall allows to connect to port 590D

sudo -i firewall-cmd --list-ports | grep 590
sudo firewall-cmd --add-port=5901/tcp --permanent
sudo firewall-cmd --reload

See also: How to configure firewall on CentOS /Oracle Linux/ Red Hat 7

Connect from the client:

To access from remote Linux system use following command.

$ vncviewer
$ gvncviewer
$ jvncviewer

To access remote desktop on vnc-server from windows system, you must have vnc-viewer installed on your system. There are various vnc viewer available to use. Download any one and install on your system, for example:

You may want to use SSL tunnel to connect to remote VNC server. See also
SSH Port Forwarding (tunnel) in Linux


Popular posts from this blog

Make online money from the Internet