Centos同一區域網路下VNC遠端桌面
一、VNC軟體
樣本由Windows控制Centos:
Centos安裝VNC
//檢查是否安裝#rpm -q tigervnc tigervnc-server//安裝#yum install tigervnc #yum install tigervnc-server//建立使用者(這一步是給系統建立使用者,覺得用已存在賬戶也行,但是一定要切換到對應賬戶下修改vnc密碼)# useradd user1# passwd user1 //切換到並修改使用者密碼# su - user1$ vncpasswd$ exit//編輯VNC設定檔vi /etc/sysconfig/vncserversVNCSERVERS="1:user1"VNCSERVERARGS[1]="-geometry 800x600"//啟動服務(監聽連接埠預設為5900+案頭號(1,2,3))service vncserver start//通過VNCviewer(centos訪問)# vncviewer 192.168.1.11:1
其餘命令:
重啟vnc:service vncserver restart關閉vnc:service vncserver stop隨系統啟動:chkconfig vncserver on關閉某個案頭號:vncserver -kill :1(冒號前有空格)更改密碼:vncpasswd(注意切換到使用者下)啟動某個案頭號:vncserver :1(冒號前有空格)
Windows安裝VNCviewer軟體,使用ip加編號訪問:
二、出現的問題
1、設定檔不對 提示:
#service vncserver startStarting VNC server: no displays configured
修改: vi /etc/sysconfig/vncservers 除去注釋,按賬戶資訊修改
VNCSERVERS="1:user1"VNCSERVERARGS[1]="-geometry 800x600"
2、字型檔不對 提示:
starting vnc server :WARNING: the first attempt to star Xvnc failed,possibly because the font catalog is not properly configured, attempting to determine an appropriate font path for this system and restart Xvnc using that font path
修改:更新字型檔
yum install pixman pixman-devel libXfont
3、沒有切換到對應賬戶下改密碼
getpassword error: Inappropriate ioctl for devicePassword:[失敗]
修改:
//切換到並修改使用者密碼# su - user1$ vncpasswd$ exit
4、串連不上: 可能centos開啟了防火牆,解決: iptables防火牆:
vim /etc/sysconfig/iptables加上:-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEP重啟:service iptables restart或關閉防火牆: service iptables stop
centos7預設防火牆:
firewall-cmd --permanent --add-service vnc-serversystemctl restart firewalld.service
不在同一區域網路: centos使用ifconfig查看網路狀態,windows使用ipconfig查看。需要同一預設閘道,同一掩碼,ip最後可不同。同時可以使用ping看通不通。
5、連VNCviewer用戶端提示串連被拒絕was refused: 到這一步,說明前面都走通了,我的在這出現問題,後來將設定檔改成如下解決:
VNCSERVERARGS[1]="-geometry 800x600"