Installing TigerVNC Server on Ubuntu
To begin, open a terminal and update your system’s package list to ensure you have access to the latest versions:
sudo apt update
Install the TigerVNC standalone server and common components, which include the server daemon and configuration files:
sudo apt install tigervnc-standalone-server tigervnc-common
Setting a VNC Password
A secure password is required to authenticate remote connections. Run the following command and follow the on-screen prompts to set a password (the maximum length is 8 characters):
vncpasswd
This creates a hidden directory ~/.vnc containing the encrypted password file (passwd).
Configuring the Desktop Environment
TigerVNC requires a startup script (xstartup) to launch your desired desktop environment (e.g., GNOME, XFCE). If the file doesn’t exist, create it in your home directory:
nano ~/.vnc/xstartup
Add the following configuration tailored to your desktop environment. For GNOME (default on many Ubuntu versions), use:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE=1
xrdb $HOME/.Xresources
startgnome &
For XFCE (lighterweight, ideal for older systems), replace the last line with:
startxfce4 &
Save the file and exit the editor. Make the script executable to allow TigerVNC to run it:
chmod +x ~/.vnc/xstartup
Starting the TigerVNC Server
Launch the VNC server with a specified display number (e.g., :1), which corresponds to TCP port 5900 + display number (5901 for :1). This starts a new session:
vncserver :1
The output will display the server’s IP and port (e.g., New 'X' desktop is your-hostname:1). To stop the server later, use:
vncserver -kill :1
Configuring the Systemd Service for Auto-Start
To ensure the VNC server starts automatically after a reboot, create a systemd service file:
sudo nano /etc/systemd/system/vncserver@.service
Paste the following content, replacing your_username with your actual Ubuntu username:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=your_username
Group=your_username
WorkingDirectory=/home/your_username
PIDFile=/home/your_username/.vnc/%H:%i.pid
ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Save the file and reload systemd to apply changes:
sudo systemctl daemon-reload
Enable the service to start on boot and launch it immediately:
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1.service
Adjusting Firewall Rules
If your Ubuntu system uses UFW (Uncomplicated Firewall), allow incoming traffic to the VNC port (5901 for display :1). Replace 5901 with your actual port if different:
sudo ufw allow 5901/tcp
Verify the rule is active:
sudo ufw status
Connecting to the Remote Desktop
On a remote computer (Windows, macOS, or Linux), install a VNC client like TigerVNC Viewer, RealVNC Viewer, or TightVNC Viewer. Open the client and enter the Ubuntu server’s IP address followed by the display number (e.g., 192.168.1.100:1). Click “Connect” and enter the VNC password you set earlier. You should now see the remote Ubuntu desktop.
Troubleshooting Common Issues
- Black/Gray Screen: This often occurs due to an incorrect
xstartupfile. Ensure the file includes commands to launch your desktop environment (e.g.,startgnome &for GNOME) and has execute permissions (chmod +x ~/.vnc/xstartup). - Connection Refused: Verify the VNC server is running (
vncserver -list), the firewall allows the port, and the systemd service is enabled. - Missing Desktop Components: Install your chosen desktop environment if not already present (e.g.,
sudo apt install ubuntu-gnome-desktopfor GNOME).
By following these steps, you can securely and efficiently use TigerVNC to remotely access your Ubuntu desktop from any compatible device.
以上就是关于“ubuntu tigervnc远程桌面怎么用”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm