Friday, March 28, 2014

CENTOS : Guide to setup VNC on Centos 6, 7 and 8

Install and configuration remote desktop VNC on Centos. 

1. Make sure the server have the desktop GUI. If not please install this GNOME desktop

#yum groupinstall "GNOME Desktop" -y

 
Centos 8

Install Desktop Environment
#sudo dnf groupinstall "Server with GUI" 

Install TigerVNC
#sudo dnf install tigervnc-server


2. Add vncserver password 

#vncpasswd

3. edit /etc/sysconfig/vncservers (Centos 6)

Centos 6 
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600"

Centos 7
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service

4. Edit /root/.vnc/xstartup to add Gnome or others desktop

Centos 6
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
exec gnome-session &

Centos 7
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
    vncserver -kill $DISPLAY
fi


Centos 8

- configure TigerVNC to use Gnome. Edit file ~/.vnc/config
- add this line 

session=gnome
geometry=1920x1200
alwaysshared

- map a user to a particular port. edit file /etc/tigervnc/vncserver.users

:1=root (or any other user name)

- edit /etc/systemd/system/vncserver@:1 service

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/usr/libexec/vncsession-start %i
PIDFile=/var/run/vncsession-%i.pid
SELinuxContext=system_u:system_r:vnc_session_t:s0

[Install]
WantedBy=multi-user.target

 5. Start VNC service.

Centos 6 - #/etc/init.d/vncserver start

Centos 7 - #vncserver

Centos 8 - #systemctl enable vncserver@:1 --now 

6. Check VNC session 

# vncserver -list

Centos 8 - #systemctl status vncserver@:1

7. To end VNC session 

# vncserver -kill :<session id>

Source :

Related Posts:

0 comments:

Post a Comment