IOS Password

設定進入特權模式密碼
有2種,如下:
(config)#enable password < word> //以明文存於組態檔
(config)#enable secret [word] //以密文存於組態檔,為單向加密
ps:若兩者同時使用,enable secret優先

…..

設定進入console終端機登入密碼
(config)#line console 0
(config-line)#login
(config-line)#password < word>
以明文存於組態檔
ps:因為只有1個控制台埠,所以只可選line console 0

…..

設定使用telnet連線登入密碼
(config)#line vty < num range>
(config-line)#login
(config-line)#password < word>
ps:cisco可能要求先輸入password,在輸入login
< num range>可設0 4代表5個vty連線,也可設0表代一個vty連線,且可同時進行
ps:switch的vty可為0 15
以明文存於組態檔
ps:若未設密碼,會拒絕遠端的連線,並顯示password required ,but none set

…..

設定使用ssh連線登入密碼

1
前置作業,設定hostname和domain-name
switch(config)# hostname < hostname >
switch(config)# ip domain-name < domainname >
2
產生ssh用的金鑰
switch(config)# crypto key generate rsa
ps:請設定768bit以符合ssh ver2最小需求
啟用認證
switch(config)# aaa new-model
設定帳密
switch(config)# username < username > password < password >
3
設定vty使用ssh
switch(config)# line vty 0 4
switch(config-line)# transport input SSH

ps:
其他ssh相關設定
switch(config)# ip ssh time-out < 1-120 >
switch(config)# ip ssh authentication-retries < 1-5 >
#show ip ssh

…….

將組態檔的所有明文密碼加密
(config)#service password-encryption
可將enable password,vty,aux,console連線的密碼在加密一次
ps:若之後還有新增明文密碼也會自動加密

ps
router(config)#line ?
vty Virtual terminal
aux Auxiliary line
console Primary terminal line

ps
#show running-config
…省略
enable secret 5 $sdf$6978yhg$jnb76sd
enable password cisco
…省略
line con 0
 login
 transport input none
 password ccna
line aux 0
line vty 0 4
 login
 password ciscoccna
…省略

…………………….

復原密碼
1
進入rom monitor
在hyperterminal中重啟設備並用ctrl+break即可進入
2
修改組態暫存器為2142
ex:cisco2600的命令
rommon>config-register 0x2142
ex:cisco2500的命令
rommon>o/r 0x2142
ps:此為加入0040忽略nvram的內容
3
重載路由器
ex:cisco2600命令
rommon>reset
ex:cisco2500命令
rommon>I
ps:重載後不要進入setup mode
4
進入特權模式複製組態檔到ram中
ex:
#copy startup-config running-config
5
改變密碼
ex:以密文方式設定enable的密碼為cisco
(config)#enable secret cisco
6
修改組態檔為原本的0x2102
ex:
(config)#config-register 0x2102
7
儲存組態
ex:拷貝ram中的組態到nvram中
#copy running-config startup-config
8
重載路由器