VNC Server configuration
Posted: 2023 May 03, 19:37
Install the necessary packages for VNC Server
Add the users we want to receive access to the VNC Server
Edit configuration file for VNC Server and add the settings for users
Add user1 password to VNC Server
Start and Stop the VNC server to check for errors
Add the VNC Server to startup
Check if the configuration file for the user (in our case it is user1) is created
In this case the configuration presents a gnome session
Add rule in firewall to allow connection to VNC Server
Start VNC Server
Code: Select all
[root @ centos ~]$ yum install vnc-server
[root @ centos ~]$ yum groupinstall Desktop
Code: Select all
[root @ centos ~]$ sudo su -
[root @ centos ~]$ useradd user1
[root @ centos ~]$ useradd user2
[root @ centos ~]$ useradd user3
[root @ centos ~]$ passwd user1
[root @ centos ~]$ passwd user2
[root @ centos ~]$ passwd user3
Code: Select all
[root @ centos ~]$ vi /etc/sysconfig/vncservers
VNCSERVERS="1:user1 2:user2 3:user3"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 640x480"
VNCSERVERARGS[3]="-geometry 800x600"
Code: Select all
[root @ centos ~]$ su - user1
[user1 @ centos ~]$ vncpasswd
[user1 @ centos ~]$ cd .vnc
[user1 @ centos .vnc]$ ls -a
passwd
Code: Select all
[root @ centos ~]$ /sbin/service vncserver start
[root @ centos ~]$ /sbin/service vncserver stop
Code: Select all
[root @ centos ~]$ /sbin/chkconfig vncserver on
In this case the configuration presents a gnome session
Code: Select all
[root @ centos ~]$ nano /home/user1/xstartup
#!/bin/sh
[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
vncconfig SecurityTypes=RA2
vncconfig RSA_Private_Key_File=$HOME/.vnc/private.key
vncconfig UserPasswdVerifier=UnixAuth
vncconfig AllowedUsers=cio:f
vncconfig AllowedGroups=staff:d
vncconfig QueryConnect=2
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
*gnome*)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
exec gnome-session
Code: Select all
[root @ centos ~]$ iptables -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5900,5901 -j ACCEPT
Code: Select all
[root @ centos ~]$ /sbin/service vncserver start