ubuntu tigervnc如何使用VNC Viewer
Prerequisites
Before using VNC Viewer to connect to an Ubuntu machine with TigerVNC, ensure the following setup is complete on the Ubuntu server:
- Install TigerVNC Server: Run
sudo apt update & & sudo apt install tigervnc-standalone-server tigervnc-common
in the terminal to install the core components. - Set a VNC Password: Execute
vncpasswd
and follow prompts to create a password (max 8 characters). This is required for client authentication. - Configure the Desktop Environment: Edit the
~/.vnc/xstartup
file to define the desktop environment (e.g., GNOME/Xfce). For GNOME, use:
Save the file, then run#!/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
chmod +x ~/.vnc/xstartup
to make it executable. - 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 withvncserver -kill :1
if you need to modifyxstartup
. - 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
- Download and Install VNC Viewer: Visit the official RealVNC or TightVNC website, download the viewer, and follow installation instructions.
- Open VNC Viewer: Launch the application from the Start menu.
- 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”. - Authenticate: Enter the VNC password you set earlier. The remote Ubuntu desktop will appear.
On macOS
- Download and Install VNC Viewer: Go to the RealVNC website, download the macOS version, and drag it to the Applications folder.
- Open VNC Viewer: Launch the app from the Applications folder.
- 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. - Authenticate: Input the VNC password. The remote desktop will load.
On Linux
- Install VNC Viewer: Use your package manager (e.g.,
sudo apt install tigervnc-viewer
for Ubuntu/Debian) to install TigerVNC Viewer. - Open VNC Viewer: Run
vncviewer
from the terminal. - Enter Connection Details: Type the Ubuntu server’s IP address and display number in the prompt (e.g.,
192.168.1.100:1
). - 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
- Gray Screen: Ensure your
~/.vnc/xstartup
file is correctly configured (e.g., uses the right desktop environment) and has execute permissions. Restart the VNC server after making changes. - Connection Refused: Verify the VNC server is running (
vncserver -list
), the firewall allows the port, and the IP address is correct. - Password Errors: If you forget the VNC password, reset it with
vncpasswd
. Note that this only changes the VNC password, not your system login password.
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: ubuntu tigervnc如何使用VNC Viewer
本文地址: https://pptw.com/jishu/731031.html