Quantcast
Channel: linoxide.com
Viewing all articles
Browse latest Browse all 1507

How to Configure TigerVNC Server on Fedora 22

$
0
0

Hi everyone, today we'll learn how to setup TigerVNC server in a machine running Fedora 22. TigerVNC is an open source virtual network computing software that was a fork of TightVNC. It focuses on performance and on remote display functionality. After its initial development, it was implemented as the default VNC software in Fedora distribution of linux. It is a powerful implementation of VNC (Virtual Network Computing) which allows users to interact with desktop environments and graphical applications on remote boxes. In VNC implementation there are two interface, one a server application that is installed and setup in the remote machine that is to be controlled with remote display, whereas the other is a client application which is installed in the machine that controls the remote machine. TigerVNC provisions a good support to run 3D and video applications, it gives look and feel of the remote machine as its in the physical box.

Here are some easy to do steps on how we can setup TigerVNC server running Mate/Xfce/Gnome desktop environments in Fedora 22 machine.

1. Installing Mate/Xfce/Gnome/LXDE

If we have a minimal edition of Fedora 22 installed in our machine, then we'll need to get a desktop environment installed in our machine. We can install any desktop environment in our Fedora 22 box but we'll go for installing any of the following desktop environment.

Installing Mate

Mate 1.10 is the latest release of mate desktop environment which is available in the official repository of Fedora 22. So, we can install Mate 1.10 in our Fedora 22 by with dnf package manager. To do so, we'll need to run the following command in a console or terminal.

# dnf groupinstall mate-desktop

Installing Xfce

Xfce 4.12 is the latest release of Xfce desktop environment and its is also available in the official repository of Fedora 22 which enables us to get it installed just by the help of dnf command.

# dnf groupinstall Xfce

Installing Gnome

Gnome 3.16 is the current release of Gnome desktop environment available in the official repository of Fedora 22. So, we can install it by running the following command.

# dnf groupinstall gnome

Installing LXDE

LXDE is the lightest fast-performing and energy saving desktop environment in linux distributions. We can install LXDE in our Fedora 22 box using the dnf command as shown below.

# dnf group install "LXDE Desktop"

2. Installing TigerVNC

After we install our required favorite desktop environment, we'll gonna install TigerVNC server in our Fedora 22 box. As TigerVNC is already available in the repository, we'll gonna install it using dnf package manager.

# dnf install tigervnc-server

3. Creating VNC user

Now, as we have installed a desktop environment and tigervnc server, we'll now create a new user named vncuser that we'll use to connect to the remote desktop running the respective desktop environment in the Fedora 22 box.

# useradd vncuser

After creating a new user named vncuser, we'll wanna set a strong user password for it. To do so, we'll gonna run the following command.

# passwd vncuser

Changing password for user vncuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Then, if we want vncuser have access to sudo mode. We'll run the following command to grant the user sudo or root access.

# usermod vncuser -a -G wheel

Note: If you already have a user created in the box and wanna use that user for VNC login, please skip this step 3.

4. Configuring VNC Server

Next, we'll gonna create a new configuration for our VNC user and specify port for the connection. To do so, we'll need to copy /lib/systemd/system/vncserver@.service file to /etc/systemd/system/vncserver@:1.service . This specifies port 5900 + 1 ie 5901 port as the name for the file is set vncserver@:1.service. If you have multiple users to VNC with, you'll need to specify a different port for that another user. We can do that by running the following command.

# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

After that, we'll gonna edit that file /etc/systemd/system/vncserver@:1.service and replace <User> with the user we wanna connect the VNC with. Here, we'll gonna replace <User> with vncuser as we have created it before.

# vi /etc/systemd/system/vncserver@:1.service

Tigervnc Service Config

After done, we'll gonna save it and exit then run the following to let systemd know that we have modified the config.

# systemctl daemon-reload

Note: To add another user to configure with VNC server, we can perform the above configurations for the next user account. Like if wanna add service to another user vncuser2 at port 2 then, we'll need to replace vncserver@:1.service with vncserver@:2.service and then replace <User> with the vncuser2 .

5. Setting up a VNC password

In order to setup a VNC password, we'll need to login into the VNC user that we just created in the above step. VNC password is the password that we'll need in future for the access of the VNC server to get remote desktop access. So, first we'll gonna login in to the user vncuser.

# su - vncuser

After we're logged into our VNC user, we'll now set a strong password using vncpasswd command.

$ vncpasswd

Password:
Verify:

6. Configuring Desktop Environment

Now, we'll gonna configure our VNC server to run a desktop environment that we have already installed. Here, we'll first run vncserver so that the necessary configuration files will be generated. To do so, we'll need to run the following command inside the user vncuser.

$ sudo systemctl start vncserver@:1

After the necessary configuration files are generated, we'll gonna stop the VNC service by running the following command.

$ sudo systemctl stop vncserver@:1

Then, we'll gonna edit the configuration file in order to specify the desktop environment we had installed above.

$ nano ~/.vnc/xstartup

Here, below are the configurations that we need to append to the file to enable those respective desktop environment.

For Mate

#!/bin/sh
#
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc
#
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &

For XFCE

#!/bin/sh
#
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc
#
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xfce4-session &

For Gnome

#!/bin/sh
#
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc
#
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

For LXDE

#!/bin/sh
#
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc
#
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startlxde &

7. Starting VNC server

Now, finally after all the configuration we'll gonna start our VNC service. We'll use systemd to start our VNC server. To do so, we'll need to run the following command.

$ sudo systemctl start vncserver@:1

Then, we'll enable vncserver to start immediately after the system boots.

$ sudo systemctl enable vncserver@:1

8. Tunneling VNC Connection to SSH

VNC connections are considered as insecure connection as they are not encrypted. So we'll gonna tunnel the VNC connection to SSH so that we can get the entire traffic encrypted and secured. To perform the tunnel, we'll need the login user, port and password of the user. Here's the command to perform the tunneling in our client machine.

$ ssh -L 5901:127.0.0.1:5901 -N -f -l vncuser 128.199.234.106

Note: Here, password will be asked to perform the tunnel. Please note that its the password for the SSH login or the user login not of the VNC password. And the port that needs to be tunneled is 5901 as shown above. The above command is to be entered in the VNC client's machine.

9. Connecting with a VNC Client

To connect to a VNC server and access the remote desktop using the ip address or domain assigned ie 127.0.0.1 as we have tunneled in above step through SSH. Here, in this tutorial, we have username as vncuser, VNC password as entered above in step 5 and port as 5901. There are plenty of VNC client available in the internet, that we can use to connect to the server. Here, we are using Remmina Remote Desktop Client as the VNC client and we'll enter the configuration as shown below.

VNC Client Config

 

Then, after we hit Connect, we're welcomed into the remote desktop access as shown below.

LXDE Desktop VNC

Note: If you are done with VNC and wanna disable the VNC server and don't want it to automatically start when system boots, here is the command that you can use to stop the vncservice and disable it to start on boot.

$ sudo systemctl disable vncserver@:1.service
$ sudo systemctl stop vncserver@:1.service

Known Issue

Sometime while figuring out with VNC, it may get crashed. And when we try to start the vncservice with systemctl, we may get some error as shown below.

$ sudo systemctl start vncserver@:1

Job for vncserver@:4.service failed. See 'systemctl status vncserver@:1.service' and 'journalctl -xn' for details.

And when we check for the error by running systemctl status vncserver@:1.service, we get similar error as shown below.

● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2015-06-29 07:47:10 UTC; 1min 14s ago
Process: 1383 ExecStart=/sbin/runuser -l vncuser -c /usr/bin/vncserver %i (code=exited, status=2)
Process: 1379 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

To Fix the Issue

In order to fix this known issue, we'll need to delete the files under /tmp/ directory. That can be done by running the following command.

$ sudo rm -rf /tmp/.X11-unix/

Conclusion

Finally, we have successfully setup and configured our VNC server named tigervnc-server with the integration of different fast light weight to beautiful desktop environments like Mate, Xfce, Gnome and LXDE in a Fedora 22 box. As all of the packages are stable and updated in the official repository of Fedora 22, it makes us very easy to setup a VNC server with that. This technology is highly useful when you have a VPS or a server far away running Fedora 22 as operating system and need to work on it with graphical stuffs. In this way, we save a lot of time in installing virtual machines in our physical machine. By following the above tutorial, we can add more multiple users with multiple desktop environments as far as the desktop environments don't crash each other. If you have any questions, suggestions, feedback please write them in the comment box below so that we can improve or update our contents. Thank you ! Enjoy :-)

The post How to Configure TigerVNC Server on Fedora 22 appeared first on LinOxide.


Viewing all articles
Browse latest Browse all 1507

Trending Articles