Skip to main content

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 yum install tigervnc-server
Add user: ( or just use existing linux user)
sudo useradd
Set VNC password for that user
vncpasswd

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

[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


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 192.168.2.198:1
$ gvncviewer 192.168.1.199:1
$ jvncviewer 192.168.1.199:1


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
Post a Comment

Popular posts from this blog

How to reset password of Jenkins

Reset password of JenkinsPrefer way, No securities were harmedSee also:
What is Jenkins' initial admin password

To reset it without disabling security if you're using matrix permissions (probably easily adaptable to other login methods): In config.xml, set disableSignup to false.Restart Jenkins.Go to the Jenkins web page and sign up with a new user.In config.xml, duplicate one of the <permission>hudson.model.Hudson.Administer:username</permission> lines and replace username with the new user.If it's a private server, set disableSignup back to true in config.xml.Restart Jenkins.Go to the Jenkins web page and log in as the new user.Reset the password of the original user.Log in as the original user. Optional cleanup: Delete the new user.Delete the temporary <permission> line in config.xml.
Alternative way:
ssh to the server, disable authentication, set the password via the Jenkins Web UI, then enable authentication.

How to Remove / Hide "Powered by Blogger" (Attribution Gadget)

Settings -> Template -> Edit HTML -> Jump to widget: choose Attribution1

Change it to:

<b:widget id='Attribution1' locked='false' mobile='no' title='' type='Attribution'/>

Go to Layout, remove Attribution1 widget.

To hide: Template -> Customize ->  Advanced -> Add CSS - Paste the following code  -> Apply to Blog:
#Attribution1 { display: none!important; }