Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»Debian»How To Install and Configure VNC Server on Debian 10

    How To Install and Configure VNC Server on Debian 10

    By RahulJune 26, 20215 Mins Read

    VNC (Virtual Network Computing) allowed to remotely control desktop systems. We can say VNC is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol (RFB). There are multiple software services provides VNC service to access Linux based desktop remotely including, TigerVNC, TightVNC, Vino, vnc4server and more.

    Advertisement

    The TigerVNC is a free, open-source and high-performance VNC server used to control or access Linux based desktop remotely. It is a client/server application that allows you to interact with graphical applications on remote machines.

    This tutorial help you to how to install and configure VNC server on Debian 10 Buster Linux system using the TigerVNC server.

    Prerequisites

    First, update and upgrade all installed packages on your system with the following command:

    sudo apt update 
    sudo apt upgrade
    

    Once your system is updated, follow the next instructions.

    Step 1 – Install Desktop Environment

    The default, Debian servers does have a Desktop Environment. TigerVNC server is designed to controls only desktop systems. So you will need to add a desktop environment in your server.

    First, install the Tasksel utility to install a desktop environment:

    sudo apt install tasksel -y 
    

    After installing Tasksel, launch the Tasksel utility with the following command:

    sudo tasksel 
    

    You should see the following interface:

    Installing Desktop on Debian 10

    1. Move cursor to Debian Desktop Environment in the list.
    2. Press the Space key to select item.
    3. Press Tab key to move cursor to Ok button.
    4. Again hit Enter to start installation.

    During installation it may prompt to choose Keyboard type and continue to install. Once all the packages are installed, you will need to set your system boots into the graphical target. You can set it with the following command:

    sudo systemctl set-default graphical.target 
    

    Next, restart your system to apply the changes.

    Step 2 – Installing VNC Server on Debian

    The TigerVNC package are available under default package repositories under Debian 10 system. You can install it by running the following command:

    sudo apt install tigervnc-standalone-server -y 
    

    After installing TigerVNC, create a new user and set a VNC password for that user.

    First, create a new user named “rahul” (or choose other name of your choice) with the following command:

    sudo adduser rahul
    

    Next, switch the user to newly created account and set a VNC password with the following command:

    su - rahul
    vncpasswd 
    

    Provide your desired password as shown below:

    Password:
    Verify:
    Would you like to enter a view-only password (y/n)? n
    

    Next, start the VNC server using the following command:

    vncserver -localhost no 
    

    Once the VNC server is started, you should get the following output:

    /usr/bin/xauth:  file /home/rahul/.Xauthority does not exist
    
    New 'tecadmin:1 (rahul)' desktop at :1 on machine tecadmin
    
    Starting applications specified in /etc/X11/Xvnc-session
    Log file is /home/rahul/.vnc/tecadmin:1.log
    
    Use xtigervncviewer -SecurityTypes VncAuth,TLSVnc -passwd /home/rahul/.vnc/passwd tecadmin:1 to connect to the VNC server.
    

    You can verify your running VNC server using the following command:

    vncserver -list 
    

    You should get the following output:

    TigerVNC server sessions:
    
    X DISPLAY #	RFB PORT #	PROCESS ID
    :1		5901		1204
    

    Step 3 – Installing VNC Client

    In this section, we will install the RealVNC VNC client on the remote machine and connect to the VNC server.

    You can download the RealVNC client from the RealVNC download page.

    Once the download is completed, install the downloaded package with the following command:

    dpkg -i /home/vyom/Downloads/VNC-Viewer-6.20.529-Linux-x64.deb  
    

    Next, launch the VNC client from the Gnome application menu. Then, Click on the File menu => New connection to create a new connection. You should see the following screen:

    Add server to vnc viewer

    Provide the Name and IP address along with VNC session ID :1 of your VNC server and click on the OK to save the connection. You should see your saved connection in the following screen:

    List of VNC servers

    Now, double click on your newly created connection. You will be asked to provide your VNC password as shown below:

    Connect to Vnc Server

    Provide your VNC password and click on the OK. Once connected, you should see your Debian desktop screen:

    Installing Vnc server on Debian 10

    Step 4 – Configure VNC to Work with Your Desktop Environment

    Before starting, stop the VNC instance using the vncserver command with a -kill option and the server session ID as an argument.

    vncserver -kill :1 
    

    You should get the following output:

    Killing Xtigervnc process ID 1719… success!

    Next, you will need to configure TigerVNC to work with Gnome. You can do it by creating new file xstartup inside .vnc directory:

    su - rahul 
    nano ~/.vnc/xstartup 
    

    Add the following lines:

    #!/bin/sh
    exec /etc/vnc/xstartup
    xrdb $HOME/.Xresources
    vncconfig -iconic &
    dbus-launch --exit-with-session gnome-session &
    

    Save and close the file when you are finished. The above script will be executed automatically whenever you start or restart the TigerVNC server.

    Next, give execute permissions to the ~/.vnc/xstartup file:

    chmod u+x  ~/.vnc/xstartup 
    

    Step 5 – Creating SystemD Unit File

    Next, you will need to create a systemd file for TigerVNC to manage the VNC service. You can create it with the following command:

    sudo nano /etc/systemd/system/[email protected] 
    

    Add the following lines:

    [Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target
    
    [Service]
    Type=simple
    User=rahul
    PAMName=login
    PIDFile=/home/%u/.vnc/%H%i.pid
    ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :
    ExecStart=/usr/bin/vncserver :%i -localhost no -geometry 1024x768
    ExecStop=/usr/bin/vncserver -kill :%i
    
    [Install]
    WantedBy=multi-user.target
    

    Save and close the file then reload the systemd daemon with the following command:

    sudo systemctl daemon-reload 
    

    Next, enable the VNC service to start at system reboot with the following command:

    sudo systemctl enable [email protected] 
    

    Next, start the VNC service with the following command:

    sudo systemctl start [email protected] 
    

    Conclusion

    Congratulations! you have successfully installed VNC server on a Debian 10 Linux Buster system. You can now connect your Debian desktop from any remote desktop systems using VNC Viewer.

    Debian 10 vnc vncserver
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Using the Apt Package Manager on Debian-based Systems

    How to Setup DKIM (DomainKeys) with Postfix

    A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

    Create a Sudo User on Debian

    How to Create a Sudo User in Debian

    View 2 Comments

    2 Comments

    1. Javier on March 25, 2022 8:53 pm

      Hi how are you? Let me just say that you forgot one step to make this to work correctly.
      The user rahul needs to be a sudo user. Without it, rahul cannot edit the service config file nor start the services.

      Reply
    2. milahu on October 23, 2021 6:39 pm

      vncpasswd
      bash: vncpasswd: command not found

      https://packages.debian.org/search?searchon=contents&keywords=vncpasswd&mode=&suite=bullseye&arch=any

      File Packages
      /usr/bin/tigervncpasswd tigervnc-common
      /usr/bin/tightvncpasswd tightvncserver [not mips]

      sudo apt install tigervnc-common

      vncpasswd
      Password:

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.