一、在Linux服務器中,我們通常是通過ssh進行遠程操作,偶爾需要有桌面支持或圖形化安裝相關軟件時,則需要遠程到服務器桌面或將輸出圖形調到客戶端。
Linux下的遠程工具通常用到的有xmanager、vnc。以下將簡單介紹vnc的應用。
step1:安裝vnc並啟動vnc
[[email protected] ~]# rpm -qa |grep vnc #需安裝以下兩個包
vnc-4.1.2-14.el5_6.6
vnc-server-4.1.2-14.el5_6.6
[[email protected] ~]# service vncserver start #啟動vnc服務
Starting VNC server: no displays configured [ OK ]
step2:修改 /etc/sysconfig/vncservers 配置文件,添加tghfly和test用戶,設置會話窗口,並使用gnome桌面
[[email protected] ~]# grep -v "#" /etc/sysconfig/vncservers
VNCSERVERS="1:tghfly 2:test" #1表示登錄會話窗口,tghfly表示登錄用戶
VNCSERVERARGS[1]="-geometry 1280x768" #遠程桌面窗口大小為1280x768
VNCSERVERARGS[2]="-geometry 1280x768"
step3:創建系統用戶tghfly和test,並設置密碼
[[email protected] ~]# useradd tghfly
[[email protected] ~]# passwd tghfly
Changing password for user tghfly.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[[email protected] ~]# useradd test
[[email protected] ~]# passwd test
Changing password for user test.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
step4:切換到tghfly和test,設置遠程登錄密碼,生成遠程認證文件
[[email protected] ~]# su - tghfly
[www.linuxidc.com@linuxidc ~]$ vncserver #使用vncserver設置當前用戶遠程登錄密碼
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/tghfly/.Xauthority
New 'hongwb.com.cn:1 (tghfly)' desktop is hongwb.com.cn:1
Creating default startup script /home/tghfly/.vnc/xstartup
Starting applications specified in /home/tghfly/.vnc/xstartup
Log file is /home/tghfly/.vnc/hongwb.com.cn:1.log