SSH 爲 Secure Shell 的縮寫,由 IETF 的網絡工作小組(Network Working Group)所制定;SSH 爲建立在應用層和傳輸層基礎上的安全協議。SSH 是目前較可靠,專爲遠程登錄會話和其他網絡服務提供安全性的協議。利用 SSH 協議可以有效防止遠程管理過程中的信息泄露問題。
VNC (Virtual Network Computer)是虛擬網絡計算機的縮寫。VNC 是一款優秀的遠程控制工具軟件,由著名的 AT&T 的歐洲研究實驗室開發的。VNC 是在基於 UNIX 和 Linux 操作系統的免費的開源軟件,遠程控制能力強大,高效實用,其性能可以和Windows 和 MAC 中的任何遠程控制軟件媲美。 在 Linux 中,VNC 包括以下四個命令:vncserver,vncviewer,vncpasswd,和 vncconnect。大多數情況下用戶只需要其中的兩個命令:vncserver 和 vncviewer。但是VNC 是明文的,不安全的.連接過程可能會被竊聽,干擾.可以使用SSH通道加密,然後再由遠程主機的迴環地址通信,加大了安全性。
下面就給大家演示一個ssh配合vncview訪問的例子。下面就給大家演示一個ssh配合vncview訪問的例子。這個例子適合redhat|Centos|OEL6以上本,redhat|Centos|OEL5配置不一樣。
1.服務端設置(192.168.1.102)
1.1 安裝vnc
[root@cent2 ~]# yum -y install tigervnc tigervnc-server
Loaded plugins: fastestmirror, refresh-packagekit, security
…………………..
…………………
Complete!
[root@cent2 ~]# rpm -qa tigervnc
tigervnc-1.1.0-8.el6_5.x86_64
[root@cent2 ~]#
1.2 修改參數文件
[root@cent2 ~]# cat /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own). You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the "-via" option in the
# `man vncviewer' manual page.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="1:oracle 2:grid"
VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp"
VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -SecurityTypes None"
[root@cent2 ~]#
主要添加了2個vnc用戶,oracle用戶和grid用戶,VNCSERVERARGS[1]表示oracle用戶分辨率和協議。但是VNCSERVERARGS[2]代表的grid用戶不用輸入密碼就可以連接。1.3 爲用戶設計vnc密碼
[root@cent2 ~]# su - oracle
[oracle@cent2 ~]$
[oracle@cent2 ~]$ vncpasswd
Password:
Verify:
[oracle@cent2 ~]$
[oracle@cent2 ~]$ exit
logout
[root@cent2 ~]#
[root@cent2 ~]# su - grid
[grid@cent2 ~]$
[grid@cent2 ~]$ vncpasswd
Password:
Verify:
[grid@cent2 ~]$
這樣做的好處,就是系統用戶密碼和vnc用戶密碼分開。1.4 啓動vnc
[root@cent2 ~]# service vncserver start
Starting VNC server: 1:oracle xauth: creating new authority file /home/oracle/.Xauthority
New 'cent2:1 (oracle)' desktop is cent2:1
Creating default startup script /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/cent2:1.log
2:grid xauth: creating new authority file /home/grid/.Xauthority
New 'cent2:2 (grid)' desktop is cent2:2
Creating default startup script /home/grid/.vnc/xstartup
Starting applications specified in /home/grid/.vnc/xstartup
Log file is /home/grid/.vnc/cent2:2.log
[ OK ]
[root@cent2 ~]#
1.5 測試
如果要連接oracle用戶,那就是5901了。這邊只是測試下,tigervnc是否配置好。下面纔是配置ssh方式的連接。
2.客戶端設置(192.168.1.103)
2.1 window客戶端
window客戶端驗證方式,我們用的工具是CRT
如果圖片,右鍵直接打開圖片的URL好了,分比率挺大的圖片。
通過上面的設置,就把服務器的5901端口映射到本地的5901了,在用vnc工具的時候,就要連接本地了。
大家看到了沒有,這裏連接的就是本地的127.0.0.1:5901了。
2.2 liunx客戶端
利用ssh 映射服務端(192.168.1.102)的5901端口 到 本地的5901端口
[root@cent1 Desktop]# ssh -L 5901:localhost:5901 192.168.1.102
The authenticity of host '192.168.1.102 (192.168.1.102)' can't be established.
RSA key fingerprint is ea:d9:cd:1e:5a:51:79:07:19:d2:e3:50:99:3f:35:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.102' (RSA) to the list of known hosts.
Address 192.168.1.102 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
[email protected]'s password:
Last login: Sun Sep 7 18:55:25 2014 from 192.168.1.101
[root@cent2 ~]#
開啓vncviewerroot@cent1 Desktop]# vncviewer 127.0.0.1:5901
TigerVNC Viewer for X version 1.1.0 - built Feb 4 2014 05:24:41
Copyright (C) 1999-2011 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Sun Sep 7 11:24:11 2014
CConn: connected to host 127.0.0.1 port 5901
CConnection: Server supports RFB protocol version 3.8
CConnection: Using RFB protocol version 3.8
Sun Sep 7 11:24:17 2014
TXImage: Using default colormap and visual, TrueColor, depth 24.
CConn: Using pixel format depth 24 (32bpp) little-endian rgb888
CConn: Using Tight encoding
這樣就配置好了,可以在liunx裏面登陸了。