路由器(Router)是連接兩個(gè)或多個(gè)網(wǎng)絡(luò)的硬件設(shè)備,在網(wǎng)絡(luò)間起網(wǎng)關(guān)的作用,是讀取每一個(gè)數(shù)據(jù)包中的地址然后決定如何傳送的專用智能性的網(wǎng)絡(luò)設(shè)備,路由器最主要的功能為實(shí)現(xiàn)信息的轉(zhuǎn)送。 思科交換機(jī)SSH配置非常基礎(chǔ),簡(jiǎn)單,官網(wǎng)也比較容易查詢,但還是記錄一下吧。
SSH的優(yōu)勢(shì)
在現(xiàn)在這個(gè)信息時(shí)代,網(wǎng)絡(luò)安全變得越來(lái)越重要,當(dāng)然路由器交換機(jī)作為數(shù)據(jù)傳輸?shù)沫h(huán)節(jié),安全性更為重要。
現(xiàn)在的網(wǎng)絡(luò)設(shè)備一般都是支持SSH和Telnet遠(yuǎn)程登錄的,新設(shè)備一般默認(rèn)建議SSH登錄。
Telnet是明文傳送,SSH是密文傳送,這是最主要的區(qū)別。
SSH替代Telnet是趨勢(shì)也是現(xiàn)實(shí)。在使用SSH的時(shí)候,一個(gè)數(shù)字證書(shū)將認(rèn)證客戶端(你的工作站)和服務(wù)器(你的網(wǎng)絡(luò)設(shè)備)之間的連接,并加密受保護(hù)的口令。SSH1使用RSA加密密鑰,SSH2使用數(shù)字簽名算法(DSA)密鑰保護(hù)連接和認(rèn)證。加密算法包括Blowfish,數(shù)據(jù)加密標(biāo)準(zhǔn)(DES),以及三重DES(3DES)。SSH保護(hù)并且有助于防止欺騙,“中間人”攻擊,以及數(shù)據(jù)包監(jiān)聽(tīng)。
通過(guò)使用SSH把所有傳輸?shù)臄?shù)據(jù)進(jìn)行加密,這樣“中間人”這種攻擊方式就不可能實(shí)現(xiàn)了,而且也能夠防止DNS和IP欺騙。還有一個(gè)額外的好處就是傳輸?shù)臄?shù)據(jù)是經(jīng)過(guò)壓縮的,所以可以加快傳輸?shù)乃俣取SH有很多功能,它既可以代替telnet,又可以為ftp、pop、甚至ppp提供一個(gè)安全的“通道”。
SSH配置
1.配置設(shè)備名稱,domain名稱,生成RSA 密鑰對(duì)
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)
要?jiǎng)h除 RSA 密鑰對(duì),請(qǐng)使用 crypto key zeroize rsa 全局配置模式命令。刪除 RSA 密鑰對(duì)之后,SSH 服務(wù)將自動(dòng)禁用。
2.配置SSH版本,超時(shí)時(shí)間,重認(rèn)證次數(shù)
test(config)#ip ssh version 2
test(config)#ip ssh time-out 90
test(config)#ip ssh authentication-retries 2
以上參數(shù)可根據(jù)實(shí)際情況自行選擇。對(duì)于比較新的iso,可以直接敲入 ip ssh time-out 90 authentication-retries 2
3.配置用戶身份驗(yàn)證和vty線路。
SSH登陸需要用戶名和密碼,所以必須要配置用戶。我這里使用的是本地認(rèn)證,實(shí)際環(huán)境中AAA認(rèn)證同理。
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
如需關(guān)閉Telnet,只開(kāi)啟SSH,敲入transport input ssh
如需同時(shí)支持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關(guān)閉,因?yàn)槿绻鹶ty 0 4啟用了SSH登錄而vty 5 15沒(méi)有,遠(yuǎn)程Telnet會(huì)繞過(guò)vty 0 4而使用vty 5 15。如下面的情況:
因此建議將vty 5 15關(guān)閉。
test(config-line)#line vty 5 15
test(config-line)#transport input none
再次登錄,就完全關(guān)閉了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
本文可以幫助您基本地設(shè)置和管理您的路由器。
|