在OSI七層模型中,這兩個安全傳輸協議其實都是建立在應用層上的
在最初的設計意圖中;
SSL(Secure Sockets Layer (SSL) and Transport Layer Security (TLS))被設計為加強Web安全傳輸(HTTP/HTTPS/)的協議(事實上還有SMTP/NNTP等) ,默認使用443端口
SSH(Secure Shell)更多的則被設計為加強Telnet/FTP安全的傳輸協議,默認地,它使用22端口.
以SSL為例,SSL在傳輸過程中所處的位置如下:
---------
| HTTP |
---------
| SSL |
---------
| TCP |
---------
| IP |
---------
如果利用SSL協議來訪問網頁,其步驟如下:
用戶:在瀏覽器的地址欄里輸入https://www.sslserver.com
HTTP層:將用戶需求翻譯成HTTP請求,如GET ? /index.htm ? ?HTTP/1.1 ? ?Host?http://www.sslserver.com
SSL層: 借助下層協議的的信道,安全的協商出一份加密密鑰,并用此密鑰來加密HTTP請求。
TCP層:與web server的443端口建立連接,傳遞SSL處理后的數據。
接收端與此過程相反。
SSL在TCP之上建立了一個加密通道,通過這一層的數據經過了加密,因此達到保密的效果。
SSL協議分為兩部分:Handshake Protocol和Record Protocol,。
其中Handshake Protocol用來協商密鑰,協議的大部分內容就是通信雙方如何利用它來安全的協商出一份密鑰。
Record Protocol則定義了傳輸的格式。
區別重解:
ssl是通訊鏈路的附加層。可以包含很多協議。https, ftps, .....
ssh只是加密的shell,最初是用來替代telnet的。通過port forward,也可以讓其他協議通過ssh的隧道而起到加密的效果。
SSL是一種國際標準的加密及身份認證通信協議,您用的瀏覽器就支持此協議。SSL(Secure Sockets Layer)最初是由美國Netscape公司研究出來的,后來成為了Internet網上安全通訊與交易的標準。SSL協議使用通訊雙方的客戶證書以及CA根證書,允許客戶/服務器應用以一種不能被偷聽的方式通訊,在通訊雙方間建立起了一條安全的、可信任的通訊通道。它具備以下基本特征:信息保密性、信息完整性、相互鑒定。 主要用于提高應用程序之間數據的安全系數。SSL協議的整個概念可以被總結為:一個保證任何安裝了安全套接字的客戶和服務器間事務安全的協議,它涉及所有TC/IP應用程序。
SSH的英文全稱是Secure Shell。通過使用SSH,你可以把所有傳輸的數據進行加密,這樣“中間人”這種攻擊方式就不可能實現了,而且也能夠防止DNS和IP欺騙。還有一個額外的好處就是傳輸的數據是經過壓縮的,所以可以加快傳輸的速度。SSH有很多功能,它既可以代替telnet,又可以為ftp、pop、甚至ppp提供一個安全的“通道”。SSH是由客戶端和服務端的軟件組成的,有兩個不兼容的版本分別是:1.x和2.x。用SSH 2.x的客戶程序是不能連接到SSH 1.x的服務程序上去的。OpenSSH 2.x同時支持SSH 1.x和2.x。
SSH的安全驗證是如何工作的?從客戶端來看,SSH提供兩種級別的安全驗證。
第一種級別(基于口令的安全驗證)只要你知道自己帳號和口令,就可以登錄到遠程主機。所有傳輸的數據都會被加密,但是不能保證你正在連接的服務器就是你想連接的服務器。可能會有別的服務器在冒充真正的服務器,也就是受到“中間人”這種方式的攻擊。
第二種級別(基于密匙的安全驗證)需要依靠密匙,也就是你必須為自己創建一對密匙,并把公用密匙放在需要訪問的服務器上。如果你要連接到SSH服務器上,客戶端軟件就會向服務器發出請求,請求用你的密匙進行安全驗證。服務器收到請求之后,先在你在該服務器的家目錄下尋找你的公用密匙,然后把它和你發送過來的公用密匙進行比較。如果兩個密匙一致,服務器就用公用密匙加密“質詢”(challenge)并把它發送給客戶端軟件。客戶端軟件收到“質詢”之后就可以用你的私人密匙解密再把它發送給服務器。用這種方式,你必須知道自己密匙的口令。
但是,與第一種級別相比,第二種級別不需要在網絡上傳送口令。第二種級別不僅加密所有傳送的數據,而且“中間人”這種攻擊方式也是不可能的(因為他沒有你的私人密匙)。但是整個登錄的過程可能需要10秒。
引用官方原文:
SSH (Secure Shell) and SSL (Secure Sockets Layer) can both be used to secure communications across the Internet. This page tries to explain the differences between the two in easily understood terms.
SSL was designed to secure web sessions; it can do more, but that's the original intent.
SSH was designed to replace telnet and FTP; it can do more, but that's the original intent.
SSL is a drop-in with a number of uses. It front-ends HTTP to give you HTTPS. It can also do this for POP3, SMTP, IMAP, and just about any other well-behaved TCP application. It's real easy for most programmers who are creating network applications from scratch to just grab an SSL implementation and bundle it with their app to provide encryption when communicating across the network via TCP. Check out: stunnel.org.
SSH is a swiss-army-knife designed to do a lot of different things, most of which revolve around setting up a secure tunnel between hosts. Some implementations of SSH rely on SSL libraries - this is because SSH and SSL use many of the same encryption algorithms (i.e. TripleDES).
SSH is not based on SSL in the sense that HTTPS is based on SSL. SSH does much more than SSL, and they don't talk to each other - the two are different protocols, but have some overlap in how they accomplish similiar goals.
SSL by itself gives you nothing - just a handshake and encryption. You need an application to drive SSL to get real work done.
SSH by itself does a whole lot of useful stuff that allows users to perform real work. Two aspects of SSH are the console login (telnet replacement) and secure file transfers (ftp replacement), but you also get an ability to tunnel (secure) additional applications, enabling a user to run HTTP, FTP, POP3, and just about anything else THROUGH an SSH tunnel.
Without interesting traffic from an application, SSL does nothing. Without interesting traffic from an application, SSH brings up an encrypted tunnel between two hosts which allows you to get real work done through an interactive login shell, file transfers, etc.
Last comment: HTTPS does not extend SSL, it uses SSL to do HTTP securely. SSH does much more than SSL, and you can tunnel HTTPS through it! Just because both SSL and SSH can do TripleDES doesn't mean one is based on the other.
總而言之,SSL提供了握手和加密手段,不是一個獨立的應用層協議,可以基于它修改現有的應用使之安全,而SSH是基于SSL之上的應用層協議,跟一般的通過SSL加密的應用層協議只是簡單的修改socket接口替換為ssl接口的機制不同,SSH是一個完全替換telnet和ftp的應用,并且可以基于之上使用端口轉發功能為其他應用層提供安全通道。