To set up VNC, follow these general steps:
1. Install VNC Server on the Host Machine
-
For Ubuntu/Debian:
sudo apt update sudo apt install tightvncserver -
For CentOS/RHEL:
sudo yum install tigervnc-server
2. Start the VNC Server
- Run the following command to start the VNC server:
vncserver - You will be prompted to set a password for VNC access.
3. Configure VNC Server
-
You may need to configure the VNC server settings. This typically involves editing the
~/.vnc/xstartupfile to start your preferred desktop environment. For example, to use the XFCE desktop, you can add:#!/bin/sh xrdb $HOME/.Xresources startxfce4 & -
Make the script executable:
chmod +x ~/.vnc/xstartup
4. Start the VNC Server Again
- After configuring, start the VNC server again:
vncserver
5. Install VNC Viewer on the Client Machine
- Download and install a VNC viewer application (like RealVNC, TightVNC, or TigerVNC) on your client machine.
6. Connect to the VNC Server
- Open the VNC viewer and enter the IP address of the host machine followed by the display number (e.g.,
192.168.1.100:1). - Enter the password you set earlier when prompted.
7. (Optional) Configure Firewall
- Ensure that the firewall on the host machine allows VNC traffic. You may need to open port 5900 plus the display number (e.g., for display
:1, open port5901).
8. (Optional) Set Up VNC as a Service
- To run VNC server automatically on boot, you can create a systemd service file. This step varies based on your Linux distribution.
Note
Make sure to secure your VNC connection, as it is not encrypted by default. Consider using SSH tunneling for secure access.
These steps provide a basic setup for VNC. Adjustments may be necessary based on your specific operating system and desktop environment.
