VNC, or Virtual Network Computing, is a powerful tool for remotely accessing and controlling desktop environments. It allows you to manage your Linux system from any device with an internet connection. While there are various VNC software options available, TigerVNC stands out as a free, open-source, and high-performance solution.
This guide will walk you through a step-by-step process of installing and configuring TigerVNC on your Ubuntu system, ensuring you can securely access your desktop from anywhere.
Step 1: Installing the Desktop Environment (If Needed)
If you're using a standard Ubuntu desktop installation, you can skip this step. However, Ubuntu Server versions do not include a desktop environment by default. Since TigerVNC is designed to control desktops, we need to install one.
First, update your system with the following commands:
apt update -y
Next, install the Tasksel utility:
Launch Tasksel with:
From the Tasksel interface, scroll down to "Ubuntu desktop" and select it using the Space key. Then, use Tab to select "OK" and press Enter to install the Ubuntu desktop.
Once the installation completes, configure your system to boot into the graphical environment:
systemctl set-default graphical.target
Restart your system for the changes to take effect.
Step 2: Installing the TigerVNC Server
TigerVNC is readily available in the default Ubuntu repositories. Install it with this command:
sudo apt install tigervnc-standalone-server -y
Now, create a dedicated user for VNC access and set a password for it. For this tutorial, we'll use "emka," but feel free to choose a different username:
Switch to the "emka" user and set a password for VNC:
Enter your desired password when prompted, and choose "n" when asked about a view-only password.
Start the VNC server using the following command:
You should see output confirming the server is running on a specific port. This output also provides the command to use a VNC client to connect to your server.
Verify your VNC server is running with:
This will list the active VNC sessions and their corresponding ports.
Step 3: Installing a VNC Client
You can download the latest VNC client from the official RealVNC download page. Once downloaded, install it with:
dpkg -i /home/emka/Downloads/VNC-Viewer-7.11.1-Linux-x64.deb
Launch the VNC client from your Gnome application menu. Click on "File" => "New connection" to create a new connection entry. Provide the name, IP address, and VNC session ID (:1) of your VNC server, then click "OK" to save the connection.
Double-click on your new connection. You will be asked to enter the VNC password you set earlier. After entering the password, you should see your Ubuntu desktop displayed on your client device.
Step 4: Configuring TigerVNC to Work with Your Desktop Environment
To ensure a smooth integration with your Gnome desktop environment, you need to configure TigerVNC settings.
First, stop any running VNC instances:
Next, create an xstartup file within your VNC user's .vnc directory:
su - emka
nano ~/.vnc/xstartup
Add the following lines to the xstartup file:
#!/bin/sh
exec /etc/vnc/xstartup
xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &
Save and close the file. This script will run automatically whenever you start or restart the TigerVNC server, ensuring proper integration with Gnome.
Make the xstartup file executable:
chmod u+x ~/.vnc/xstartup
Step 5: Setting Up a Systemd Service for Automatic Startup
Using a systemd service ensures your VNC server starts automatically whenever your system boots. Create a systemd configuration file for TigerVNC:
nano /etc/systemd/system/[email protected]
Paste the following content into the file:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
User=emka
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.
Reload the systemd daemon:
Enable the VNC service to start automatically on system boot:
systemctl enable [email protected]
Start the VNC service now:
systemctl start [email protected]
Conclusion
Congratulations! You have successfully installed and configured TigerVNC on your Ubuntu system. Now, you can conveniently access and control your Ubuntu desktop from any device with an internet connection. This allows you to manage your system, run applications, and work remotely with ease.
0 comments:
Post a Comment