路由器(Router)是連接兩個或多個網絡的硬件設備,在網絡間起網關的作用,是讀取每一個數據包中的地址然后決定如何傳送的專用智能性的網絡設備,路由器最主要的功能為實現信息的轉送。 思科交換機SSH配置非常基礎,簡單,官網也比較容易查詢,但還是記錄一下吧。
SSH的優勢
在現在這個信息時代,網絡安全變得越來越重要,當然路由器交換機作為數據傳輸的環節,安全性更為重要。
現在的網絡設備一般都是支持SSH和Telnet遠程登錄的,新設備一般默認建議SSH登錄。
Telnet是明文傳送,SSH是密文傳送,這是最主要的區別。
SSH替代Telnet是趨勢也是現實。在使用SSH的時候,一個數字證書將認證客戶端(你的工作站)和服務器(你的網絡設備)之間的連接,并加密受保護的口令。SSH1使用RSA加密密鑰,SSH2使用數字簽名算法(DSA)密鑰保護連接和認證。加密算法包括Blowfish,數據加密標準(DES),以及三重DES(3DES)。SSH保護并且有助于防止欺騙,“中間人”攻擊,以及數據包監聽。
通過使用SSH把所有傳輸的數據進行加密,這樣“中間人”這種攻擊方式就不可能實現了,而且也能夠防止DNS和IP欺騙。還有一個額外的好處就是傳輸的數據是經過壓縮的,所以可以加快傳輸的速度。SSH有很多功能,它既可以代替telnet,又可以為ftp、pop、甚至ppp提供一個安全的“通道”。
SSH配置
1.配置設備名稱,domain名稱,生成RSA 密鑰對
Switch#configure terminal
Switch(config)#hostname test
test(config)#ip domain-name hello2099.com
test(config)#crypto key generate rsa
The name for the keys will be: test.hello2099.com
Choose the size of the key modulus in the range of 360 to 4096 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable…
[OK] (elapsed time was 0 seconds)
要刪除 RSA 密鑰對,請使用 crypto key zeroize rsa 全局配置模式命令。刪除 RSA 密鑰對之后,SSH 服務將自動禁用。
2.配置SSH版本,超時時間,重認證次數
test(config)#ip ssh version 2
test(config)#ip ssh time-out 90
test(config)#ip ssh authentication-retries 2
以上參數可根據實際情況自行選擇。對于比較新的iso,可以直接敲入 ip ssh time-out 90 authentication-retries 2
3.配置用戶身份驗證和vty線路。
SSH登陸需要用戶名和密碼,所以必須要配置用戶。我這里使用的是本地認證,實際環境中AAA認證同理。
test(config)#username cisco secret cisco
test(config)#enable secret cisco
test(config)#line vty 0 4
test(config-line)#login local
test(config-line)#transport input ssh
如需關閉Telnet,只開啟SSH,敲入transport input ssh
如需同時支持SSH和Telnet,敲入transport input all
test(config-line)#transport input ?
all All protocols
none No protocols
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
一般情況下line vty 0 4配置完成后,建議將vty 5 15關閉,因為如果vty 0 4啟用了SSH登錄而vty 5 15沒有,遠程Telnet會繞過vty 0 4而使用vty 5 15。如下面的情況:
因此建議將vty 5 15關閉。
test(config-line)#line vty 5 15
test(config-line)#transport input none
再次登錄,就完全關閉了Telnet,只能使用SSH。
4.檢查SSH登錄
test#show ssh
Connection Version Mode Encryption Hmac State Username
0 2.0 IN aes256-ctr hmac-sha1 Session started cisco
0 2.0 OUT aes256-ctr hmac-sha1 Session started cisco
%No SSHv1 server connections running.
test#show ip ssh
SSH Enabled – version 2.0
Authentication methods:publickey,keyboard-interactive,password
Encryption Algorithms:aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
MAC Algorithms:hmac-sha1,hmac-sha1-96
Authentication timeout: 90 secs; Authentication retries: 2
Minimum expected Diffie Hellman key size : 1024 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded):
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNYkHIP4uyK+jxLV6n3AlBtUaa6O53K9u2qrtQQu+v
jdmW9vhhsiFaDUDf4fROkczE+6FskpgeqEdP6MtqxCO8CNAPIxqDIYR/bBGtWBhhEsPmrgpQBGWCKSyJ
aRBLdeCRJXmYLEDZXCcEtmJQf6Iu7zCV9ZMxO0A1/2B4Si9Dgw==
配置范例
Switch(config)# hostname test
test(config)# ip domain-name hello2099.com
test(config)# crypto key generate rsa
test(config)# ip ssh version 2
test(config)# ip ssh time-out 90
test(config)# ip ssh authentication-retries 2
test(config)# username cisco secret cisco
test(config)# enable secret cisco
test(config)# line vty 0 4
test(config-line)# login local
test(config-line)# transport input ssh
test(config)# line vty 5 15
test(config-line)# transport input none
本文可以幫助您基本地設置和管理您的路由器。
|