• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

TinyGrab

Your Trusted Source for Tech, Finance & Brand Advice

  • Personal Finance
  • Tech & Social
  • Brands
  • Terms of Use
  • Privacy Policy
  • Get In Touch
  • About Us
Home » How to install VNC server in Ubuntu?

How to install VNC server in Ubuntu?

June 4, 2025 by TinyGrab Team Leave a Comment

Table of Contents

Toggle
  • Mastering Remote Access: Installing a VNC Server on Ubuntu
    • Step-by-Step Installation of TigerVNC on Ubuntu
      • 1. Update Your System
      • 2. Install TigerVNC Server
      • 3. Configure the VNC Password
      • 4. Configure the VNC Server
      • 5. Start the VNC Server
      • 6. Connect to the VNC Server
    • 12 Frequently Asked Questions (FAQs) about VNC on Ubuntu

Mastering Remote Access: Installing a VNC Server on Ubuntu

Remote access is no longer a luxury; it’s a necessity. Whether you’re troubleshooting a server from across the globe, collaborating with colleagues, or simply accessing your desktop from another room, having a reliable remote access solution is crucial. Virtual Network Computing (VNC) is a powerful and versatile tool that provides just that. In this guide, we’ll delve into the intricacies of installing and configuring a VNC server on Ubuntu, ensuring a seamless and secure remote desktop experience.

How to install VNC server in Ubuntu? It’s a multi-step process that involves installing the necessary packages, configuring the server, and establishing a secure connection. We’ll use TigerVNC, a popular and lightweight VNC server, as our example.

Step-by-Step Installation of TigerVNC on Ubuntu

Let’s dive into the nitty-gritty. We’ll cover everything from updating your system to establishing a secure SSH tunnel.

1. Update Your System

Before you begin, ensure your Ubuntu system is up-to-date. This minimizes potential conflicts and ensures you have the latest security patches. Open your terminal and execute the following commands:

sudo apt update sudo apt upgrade 

2. Install TigerVNC Server

With your system updated, it’s time to install the TigerVNC server. This can be easily done using the apt package manager:

sudo apt install tigervnc-standalone-server tigervnc-common 

3. Configure the VNC Password

Once the installation is complete, you’ll need to set a password for your VNC server. This password is used to authenticate connections. Run the following command:

vncpasswd 

You’ll be prompted to enter and confirm a password. It’s crucial to choose a strong password to protect your system. You’ll also be asked if you want to set up a view-only password. If you want to grant someone the ability to view your screen without being able to control it, set this password.

4. Configure the VNC Server

Now, we need to configure the VNC server to launch your preferred desktop environment. TigerVNC relies on a configuration file named ~/.vnc/xstartup to determine what to execute when a VNC session is started. First, stop any running VNC server instances:

vncserver -kill :1 

This command kills the VNC server running on display :1. If you haven’t started any VNC servers yet, this command might give an error, which is perfectly fine.

Next, create and edit the ~/.vnc/xstartup file. Use your favorite text editor:

nano ~/.vnc/xstartup 

Add the following content to the file:

#!/bin/bash unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & x-window-manager & gnome-session & # Or start your preferred desktop environment 

Important: Replace gnome-session & with the command to start your preferred desktop environment if you are not using GNOME. For example, if you’re using XFCE, replace it with startxfce4 &.

Make the xstartup file executable:

chmod +x ~/.vnc/xstartup 

5. Start the VNC Server

Now, you can start the VNC server. The first time you start the VNC server, it will create the necessary configuration files.

vncserver -geometry 1920x1080 :1 

This command starts the VNC server on display :1 with a resolution of 1920×1080. You can adjust the resolution to suit your needs. Note the assigned port number, usually 5901 for display :1, 5902 for display :2 and so on.

6. Connect to the VNC Server

You can now connect to your VNC server using a VNC client. However, for security reasons, it’s highly recommended to establish an SSH tunnel to encrypt the VNC connection.

Open a new terminal on your local machine and create an SSH tunnel:

ssh -L 5901:localhost:5901 username@your_server_ip 

Replace username with your Ubuntu username and your_server_ip with the IP address of your Ubuntu server. This command forwards port 5901 on your local machine to port 5901 on the remote server through an encrypted SSH tunnel.

Now, use a VNC client (e.g., TigerVNC Viewer, RealVNC Viewer) and connect to localhost:5901. Enter the VNC password you set earlier.

Congratulations! You have successfully installed and configured a VNC server on Ubuntu.

12 Frequently Asked Questions (FAQs) about VNC on Ubuntu

Here are some common questions about installing and using VNC on Ubuntu:

  1. What is the difference between VNC and RDP?

    VNC and RDP are both remote desktop protocols, but they differ in their architecture. VNC is platform-independent and operates at the frame buffer level, meaning it shares the same desktop session. RDP, on the other hand, is primarily used for Windows and creates a separate session for each user. RDP generally offers better performance on Windows systems.

  2. Why should I use an SSH tunnel for VNC?

    VNC connections are not encrypted by default, making them vulnerable to eavesdropping. An SSH tunnel encrypts the entire VNC session, protecting your data and credentials from being intercepted. Using an SSH tunnel is crucial for security, especially when connecting over a public network.

  3. How do I change the VNC server resolution?

    You can change the VNC server resolution by modifying the vncserver command when starting the server. For example, to set the resolution to 1280×720, use the command vncserver -geometry 1280x720 :1.

  4. How do I start the VNC server automatically on boot?

    To start the VNC server automatically on boot, you can create a systemd service file. Create a file named /etc/systemd/system/vncserver@:1.service (replace :1 with the display number you want to use) and add the following content, replacing <username> with your actual username:

    [Unit] Description=VNC Server on :1 After=network.target  [Service] User=<username> WorkingDirectory=/home/<username>  PIDFile=/home/<username>/.vnc/%H:%i.pid ExecStart=/usr/bin/vncserver :1 -geometry 1920x1080 ExecStop=/usr/bin/vncserver -kill :1  [Install] WantedBy=multi-user.target 

    Then, enable and start the service:

    sudo systemctl enable vncserver@:1.service sudo systemctl start vncserver@:1.service 
  5. How do I connect to the VNC server from Windows?

    You can use a VNC client like TigerVNC Viewer or RealVNC Viewer on Windows to connect to your Ubuntu VNC server. After setting up an SSH tunnel as described above, enter localhost:5901 (or the appropriate display number) in the VNC client and provide the VNC password.

  6. I get a blank screen when I connect to the VNC server. What could be the issue?

    A blank screen often indicates a problem with the desktop environment not starting correctly. Ensure that the ~/.vnc/xstartup file is configured correctly and that it includes the command to start your preferred desktop environment (e.g., gnome-session &, startxfce4 &). Also, check the file permissions to ensure the xstartup file is executable.

  7. How do I reset the VNC password?

    To reset the VNC password, simply run the vncpasswd command again. This will prompt you to enter a new password.

  8. Can I use VNC over the internet without an SSH tunnel?

    While it’s technically possible, it’s strongly discouraged due to security risks. VNC without encryption is vulnerable to eavesdropping and man-in-the-middle attacks. Always use an SSH tunnel to encrypt the connection when connecting over the internet. Consider VPN alternatives also for enhanced security.

  9. How do I kill a running VNC server session?

    You can kill a running VNC server session using the command vncserver -kill :<display_number>. For example, to kill the VNC server running on display :1, use the command vncserver -kill :1.

  10. How do I troubleshoot VNC connection problems?

    Troubleshooting VNC connections involves checking several factors:

    • Network Connectivity: Ensure that your server is reachable over the network and that there are no firewall rules blocking the VNC port (5900 + display number).
    • SSH Tunnel: Verify that the SSH tunnel is correctly established and forwarding the correct ports.
    • VNC Server Status: Confirm that the VNC server is running on the remote machine.
    • Firewall: Ensure that firewall settings on both the client and server allow connections to the relevant ports (5900+n).
    • VNC Client Settings: Double-check the VNC client settings, including the server address, port number, and password.
  11. Can I install multiple VNC servers on the same Ubuntu machine?

    Yes, you can install and run multiple VNC servers on the same machine. Each VNC server instance will run on a different display number (e.g., :1, :2, :3). You’ll need to configure each VNC server instance separately.

  12. What alternatives are there to TigerVNC?

    While TigerVNC is a popular choice, other VNC server options include RealVNC, TightVNC, and x11vnc. Each has its own strengths and weaknesses, so it’s worth exploring them to find the best fit for your needs. RealVNC is often considered more robust commercially while x11vnc can connect to an existing X session.

By following these steps and addressing these common questions, you can successfully install and configure a VNC server on Ubuntu, enabling secure and convenient remote access to your system. Remember, security is paramount, so always prioritize using an SSH tunnel to protect your VNC connections. Embrace the power of remote access, and unlock new levels of productivity and flexibility.

Filed Under: Tech & Social

Previous Post: « Is the Google Translate API free?
Next Post: How to change your Spotify card payment? »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

NICE TO MEET YOU!

Welcome to TinyGrab! We are your trusted source of information, providing frequently asked questions (FAQs), guides, and helpful tips about technology, finance, and popular US brands. Learn more.

Copyright © 2025 · Tiny Grab