Router#configure terminal
Router(config)#hostname R2 //配置ssh的時候路由器的名字不能爲router
R2(config)#ip domain-name cisco.com
R2(config)#username best password best1
注:添加一個用戶:best,口令:best1
R2(config)#line vty 0 4
R2(config-line)#transport input ssh
交換引擎session!)
2. 配置SSH服務:
R2(config)#crypto key generate rsa
The name for the keys will be: R2.cisco.com
注:SSH的關鍵字名就是hostname + . +ip domain-name
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minuts
How many bits in the modulus [512]: 注:選擇加密位數,cisco推薦使用1024
Generating RSA keys ...
[OK]
用命令show ip ssh也能看到:
SSH Enabled - version 1.5
Authentication timeout: 120 secs; Authentication retries:
現在SSH服務已經啓動,如果需要停止SSH服務,用以下命令:
R2(config)#crypto key zeroize rsa
3.設置SSH參數
配置好了SSH之後,通過show run命令我們看到SSH默認的參數:超時限定爲120秒,認證重試次數爲3次,可以通過下面命令進行修改:
R2(config)#ip ssh {[time-out seconds]} │ [authentication-retries interger]}
如果要把超時限定改爲180秒,則應該用:
R2(config)# ip ssh time-out 180
如果要把重試次數改成5次,則應該用:
R2(config)# ip ssh authentication-retries
這樣,SSH已經在路由器上配置成功了,就能夠通過SSH進行安全登錄了。
注意:最後如果從別的設備用ssh登錄這臺路由器會出現以下內容:
R1#ssh -l best 192.168.0.2
Password:
在Cisco Native IOS上啓用SSH,禁止Telnet | |
命令 | 描述 |
username admin1 privilege 15 password 0 Admin-Password | 建立一個叫做admin1的系統管理員,每一個管理都必須重複。 |
aaa new-model | 使用一個本地數據庫,設置爲AAA模式 |
aaa authentication login default local | |
aaa authorization exec default local | |
aaa authorization network default local | |
aaa session-id common | |
ip domain name MyDomain.com | 建立一個用於認證的名字 |
crypto key generate rsa | 建立數字證書。使用至少768位的Diffie-Hellman關鍵字 |
line vty 0 4 | 進入vty配置 |
transport input ssh | 僅僅允許SSH登錄 |