ubuntu

ubuntu tigervnc如何使用VNC Viewer

小樊
42
2025-10-21 06:31:15
栏目: 智能运维

Prerequisites
Before using VNC Viewer to connect to an Ubuntu machine with TigerVNC, ensure the following setup is complete on the Ubuntu server:

  1. Install TigerVNC Server: Run sudo apt update && sudo apt install tigervnc-standalone-server tigervnc-common in the terminal to install the core components.
  2. Set a VNC Password: Execute vncpasswd and follow prompts to create a password (max 8 characters). This is required for client authentication.
  3. Configure the Desktop Environment: Edit the ~/.vnc/xstartup file to define the desktop environment (e.g., GNOME/Xfce). For GNOME, use:
    #!/bin/sh
    unset SESSION_MANAGER
    unset DBUS_SESSION_BUS_ADDRESS
    export XDG_SESSION_TYPE=x11
    export GNOME_SHELL_SESSION_MODE=ubuntu
    exec dbus-launch --exit-with-session gnome-session
    
    Save the file, then run chmod +x ~/.vnc/xstartup to make it executable.
  4. Start the VNC Server: Launch a session with vncserver :1 (replace :1 with your desired display number). This outputs the port number (e.g., 5901 for :1). Stop the server with vncserver -kill :1 if you need to modify xstartup.
  5. Configure Firewall (if enabled): Allow VNC traffic by running sudo ufw allow 5901/tcp (adjust port if using a different display number).

Using VNC Viewer to Connect
VNC Viewer is available for Windows, macOS, and Linux. Below are steps for common platforms:

On Windows

  1. Download and Install VNC Viewer: Visit the official RealVNC or TightVNC website, download the viewer, and follow installation instructions.
  2. Open VNC Viewer: Launch the application from the Start menu.
  3. Enter Connection Details: In the “New Connection” window, enter the Ubuntu server’s IP address followed by the display number (e.g., 192.168.1.100:1 for :1). Click “Connect”.
  4. Authenticate: Enter the VNC password you set earlier. The remote Ubuntu desktop will appear.

On macOS

  1. Download and Install VNC Viewer: Go to the RealVNC website, download the macOS version, and drag it to the Applications folder.
  2. Open VNC Viewer: Launch the app from the Applications folder.
  3. Enter Connection Details: Type the Ubuntu server’s IP address and display number in the address bar (e.g., 192.168.1.100:1). Press Enter.
  4. Authenticate: Input the VNC password. The remote desktop will load.

On Linux

  1. Install VNC Viewer: Use your package manager (e.g., sudo apt install tigervnc-viewer for Ubuntu/Debian) to install TigerVNC Viewer.
  2. Open VNC Viewer: Run vncviewer from the terminal.
  3. Enter Connection Details: Type the Ubuntu server’s IP address and display number in the prompt (e.g., 192.168.1.100:1).
  4. Authenticate: Enter the VNC password. The remote desktop will display.

Optional: Enhance Security with SSH Tunneling
To encrypt VNC traffic, set up an SSH tunnel between your local machine and the Ubuntu server. On your local machine, run:

ssh -L 5901:localhost:5901 your_username@your_server_ip

Replace your_username and your_server_ip with your actual credentials. Then, connect VNC Viewer to localhost:1 (or localhost:<display_number>). This routes traffic through SSH, securing the connection.

Troubleshooting Common Issues

0
看了该问题的人还看了