frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

[Debian] XFCE usage for VNC access to your Debian 8 server.

WilliamWilliam Moderator
edited September 2018 in Linux Applications

This guide will show XFCE desktop environment usage on server with Debian 8, connecting to it via VNC client for managing your server via GUI. Why XFCE? Because it has lower resource consumption than other environments so more resources will be for your services usage!

Requirements:
Linux server with Debian OS installed.

1. Update your OS template packages and upgrade them:

apt-get update

apt-get upgrade -y

2. Install the required xfce and vnc packages to your server (here we will be using tightvncserver, since it has low resource consumption, but you can use alternatives also):

apt-get install xfce4 xfce4-goodies gnome-icon-theme tightvncserver
3. When the installation will be completed, recommendation is to create a separate user for the VNC connections instead of root (example "username" can be changed as you like). When creating the user, you will be asked to also set a password for it. You can skip the details by pressing Enter for each:

adduser username

4. When the user will be created, log-in to the created user and start the vncserver, so that it would generate the required settings and password:

su - username

The VNC server can be started via the following command:

vncserver

After starting the server for the first time, you will be requested to create a password for it, that will be used afterwards of connecting the server from your VNC client.

TIP: If you wish to stop VNC: vncserver -kill :1       <- the :1 identifies the display number that will be stopped.

5. Before proceeding, make sure that VNC server is stopped by using previously provided command. Get back to the root user (you can use "exit" in console to log off from the created user). Configure the management of VNC connection:

nano /usr/local/bin/vncsrv

Add the following code in the file (you can test with the settings as it will adjust your VNC connection details):
#!/bin/bash
PATH="$PATH:/usr/bin/"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

case "$1" in
start)
/usr/bin/vncserver ${OPTIONS}
;;

stop)
/usr/bin/vncserver -kill :${DISPLAY}
;;

restart)
$0 stop
$0 start
;;
esac
exit 0
Make the created file executable:

chmod +x /usr/local/bin/vncsrv

6. Create a file that would start the service and add the following contents into it::
nano /lib/systemd/system/vncsrv.service
The contents:
[Unit]
Description=Manage VNC Server on this user

[Service]
Type=forking
ExecStart=/usr/local/bin/vncsrv start
ExecStop=/usr/local/bin/vncsrv stop
ExecReload=/usr/local/bin/vncsrv restart
User=username

[Install]
WantedBy=multi-user.target
Take notice that in the used code, "User" should be your created additional user from 3rd step.

7. Now you can reload the systemctl and enable the vnc service:

systemctl daemon-reload

systemctl enable vncsrv.service

That's it. You can now start the service manually by using "vncserver" or you can simply reboot the server and the service will be running automatically. For accessing the server via your VNC client, you should use server IP and 5901 port and the password that you have set for your user, for example:

12.34.5.67:5901
Tagged:
Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch