Difference between revisions of "Redhat7:Installing VNC"

From Define Wiki
Jump to navigation Jump to search
(Created page with "== VNC Server == == Installing the VNC server == The VNC server can be installed easily with YUM: <syntaxhighlight> yum -y install tigervnc-server </syntaxhighlight>")
 
Line 2: Line 2:
  
  
== Installing the VNC server ==
+
=== Installing the VNC server ===
  
  
Line 8: Line 8:
  
 
<syntaxhighlight>
 
<syntaxhighlight>
 +
yum groupinstall "GNOME Desktop"
 
yum -y install tigervnc-server
 
yum -y install tigervnc-server
 +
</syntaxhighlight>
 +
 +
=== Adding VNC User ===
 +
 +
<syntaxhighlight>
 +
useradd boston
 +
passwd boston
 +
</syntaxhighlight>
 +
 +
In CentOS 7.0 there is change in the vncserver configuration file. Before ContOS 7.0 it was  <tt>/etc/sysconfig/vncservers<tt> and now it have changed in <tt>/lib/systemd/system/vncserver@.service<tt>. Next I will use the original file and create the configuration file as shown:
 +
 +
<syntaxhighlight>
 +
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
 +
#Now we will edit the file as follows:
 +
vi /etc/systemd/system/vncserver@:1.service
 +
</syntaxhighlight>
 +
 +
Replace the string <USER> with appropriate vncuser’s username.  In my case I will be using the user boston just created above:
 +
<syntaxhighlight>
 +
[...]
 +
[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
 +
ExecStart=/sbin/runuser -l boston -c "/usr/bin/vncserver %i"
 +
PIDFile=/home/boston/.vnc/%H%i.pid
 +
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
 +
</syntaxhighlight>
 +
 +
If you wish to add more users you would create a new vncserver@:#.service file and change the <USER> string to the new users.
 +
 +
Firewall settings:
 +
<syntaxhighlight>
 +
firewall-cmd --permanent --zone=public --add-service vnc-server
 +
firewall-cmd --reload
 +
 +
#Now switch to the vncuser just created above and start the vnc service as:
 +
su - boston
 +
vncserver
 +
 +
[boston@server1 ~]$ vncserver
 +
 +
#You will require a password to access your desktops.
 +
 +
Password:<yourvncpassword>
 +
Verify:<yourvncpassword>
 +
xauth:  file /home/srijan/.Xauthority does not exist
 +
 +
New 'server1.example.com:1 (boston)' desktop is server1.example.com:1
 +
 +
Creating default startup script /home/boston/.vnc/xstartup
 +
Starting applications specified in /home/boston/.vnc/xstartup
 +
Log file is /home/boston/.vnc/server1.example.com:1.log
 +
 +
[boston@server1 ~]$
 +
 +
#Now make the service enabled on after every reboot with root credentials:
 +
su -
 +
systemctl daemon-reload
 +
 +
systemctl enable vncserver@:1.service
 +
 +
reboot
 +
systemctl start vncserver@:1.service
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 16:53, 8 December 2015

VNC Server

Installing the VNC server

The VNC server can be installed easily with YUM:

yum groupinstall "GNOME Desktop"
yum -y install tigervnc-server

Adding VNC User

useradd boston
passwd boston

In CentOS 7.0 there is change in the vncserver configuration file. Before ContOS 7.0 it was /etc/sysconfig/vncservers and now it have changed in /lib/systemd/system/vncserver@.service. Next I will use the original file and create the configuration file as shown:

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
#Now we will edit the file as follows:
vi /etc/systemd/system/vncserver@:1.service

Replace the string <USER> with appropriate vncuser’s username. In my case I will be using the user boston just created above:

[...]
[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
ExecStart=/sbin/runuser -l boston -c "/usr/bin/vncserver %i"
PIDFile=/home/boston/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

If you wish to add more users you would create a new vncserver@:#.service file and change the <USER> string to the new users.

Firewall settings:

firewall-cmd --permanent --zone=public --add-service vnc-server
firewall-cmd --reload

#Now switch to the vncuser just created above and start the vnc service as:
su - boston
vncserver

[boston@server1 ~]$ vncserver

#You will require a password to access your desktops.

Password:<yourvncpassword>
Verify:<yourvncpassword>
xauth:  file /home/srijan/.Xauthority does not exist

New 'server1.example.com:1 (boston)' desktop is server1.example.com:1

Creating default startup script /home/boston/.vnc/xstartup
Starting applications specified in /home/boston/.vnc/xstartup
Log file is /home/boston/.vnc/server1.example.com:1.log

[boston@server1 ~]$

#Now make the service enabled on after every reboot with root credentials:
su -
systemctl daemon-reload

systemctl enable vncserver@:1.service

reboot
systemctl start vncserver@:1.service