VNC server on Centos 7
a) yum groupinstall “X Window System”
b) yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
unlink /etc/systemd/system/default.target
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
reboot
After reboot, you will get Centos 7 desktop .
Now start installing VNC packages.
Issue the below command to install VNC package.
yum install tigervnc-server -y
Create a file vncserver@:1.service in /etc/systemd/system/ directory by copying example config file /lib/systemd/system/vncserver@.service
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
Now open /etc/systemd/system/vncserver@:1.service file and replace with your username .
Find these lines ..
ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”
PIDFile=/home/<USER>/.vnc/%H%i.pid
Replace ( Considering username as mohan )
ExecStart=/sbin/runuser -l mohan -c “/usr/bin/vncserver %i”
PIDFile=/home/mohan/.vnc/%H%i.pid
If you are creating for root user .
ExecStart=/sbin/runuser -l root -c “/usr/bin/vncserver %i”
PIDFile=/root/.vnc/%H%i.pid
Reload systemd for changes.
systemctl daemon-reload
Create VNC password for the user .
su – mohan
vncpasswd
Enable and start the service using the below commands.
Enable service at startup ( Permanent ).
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service
Allow VNC service in firewall.
firewall-cmd –permanent –add-service vnc-server
systemctl restart firewalld.service
You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
For additional users create files with different ports ( Refer Step 2 ) vncserver@:2.service by copying example config file and continue the steps 3,4,5 and 6 by replacing service name. Please make sure you logged in as that particular user for creating vnc password ( Step 5 ).
Additional Commands :
To stop VNC service .
systemctl stop vncserver@:1.service
To disable VNC service from startup ( permanent ).
systemctl disable vncserver@:1.service
To stop firewall ( For troubleshooting ).
Recent Comments