Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

CentOS 6.3 安裝配置 VNC 遠端桌面完整教學(GNOME/KDE + TigerVNC)

編輯:關於 Linux

VNC 提供 Linux 圖形化遠端桌面存取。CentOS 6.3 安裝 VNC 需先安裝桌面環境(GNOME/KDE),再部署 TigerVNC Server、設定使用者密碼、配置 /etc/sysconfig/vncservers、啟動服務並設定開機自啟。

1. 安裝桌面環境(二選一或皆裝)

# GNOME
yum -y groupinstall "GNOME Desktop Environment"

# KDE
yum groupinstall "X Window System" "KDE (K Desktop Environment)"

2. 安裝 TigerVNC Server

yum -y install vnc-server
# 實際安裝套件:tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686

3. 設定 VNC 使用者密碼

su - jackiebui
vncpasswd
# 輸入兩次密碼,產生 ~/.vnc/passwd

4. 編輯 VNC 服務配置

vi /etc/sysconfig/vncservers
# 取消註解並修改最後兩行:
VNCSERVERS="1:jackiebui"
VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -localhost"
# -geometry:解析度
# -nolisten tcp:禁用 TCP 連線(安全)
# -localhost:僅允許本地/SSH 隧道連線

5. 啟動服務與開機自啟

service vncserver start
chkconfig vncserver on

# 驗證埠口(5900 + display 號)
netstat -tlnp | grep 5901
# tcp  0  0 127.0.0.1:5901  0.0.0.0:*  LISTEN  1234/Xvnc

6. 客戶端連線

  • 建立 SSH 隧道:ssh -L 5901:localhost:5901 user@server_ip
  • VNC Viewer 連線:localhost:1 或 localhost:5901。

VNC 安裝過程截圖

安全性建議

  • 務必啟用 -localhost 並透過 SSH 隧道連線,避免 VNC 明文密碼在網路傳輸。
  • 配合 iptables 僅開放 SSH 埠口 (22)。
  • 定期更換 VNC 密碼:vncpasswd。
  • 考慮使用 x11vnc + systemd 服務(CentOS 7+)或 TigerVNC systemd 服務單元。

常見問題

  • 灰色畫面/只有終端機:桌面環境未正確啟動,檢查 ~/.vnc/xstartup 含 gnome-session & 或 startkde &。
  • 連線被拒絕:確認 VNCSERVERARGS 中 -localhost 與 SSH 隧道埠口轉發正確。
  • 解析度不符:調整 -geometry 參數。
Copyright © Windows教程網 All Rights Reserved