cisco TELNET、SSH 、AAA 設置

                                            cisco  TELNETSSH AAA 設置

 

1.    telnet       基於TCP協議  23端口

 A 方法一:只使用密碼即可登入:

Switch(config)#enable password 123456                              設置特權密碼

Switch(config)#line vty 0 4

Switch(config-line)#password 123456           設置登入密碼

Switch(config-line)#login                    允許登入

image.png

                                             

Switch(config-line)#exit

 B 方法二:只允許使用用戶名和密碼登入:

Switch(config)#username admin privilege 5 password 123456     添加用戶名密碼

Switch(config)#enable password 123456                                       設置特權密碼

Switch(config)#line vty 0 4                使用0至4的虛擬遠程

Switch(config-line)#login local            允許本地用戶登入

Switch(config-line)#transport input  telnet      允許接入telnet連接

Switch(config-line)#exit

 

image.png

 

 

 C  ACL限制:

 

image.png

上圖沒限制前所有客戶端都可以訪問

 

Switch(config)#line vty 0 4

Switch(config-line)#login local

Switch(config-line)#access-class 100 in                                                  在入方向調用ACL

Switch(config)#access-list 100 permit ip host 192.168.20.254 any         表示只允許20.254訪問

 

限制後驗證:

image.png

允許192.168.20.254 telnet驗證:

image.png


2.    SSH  基於tcp 協議  22端口

 

例如:

Switch(config)#hostname sw1                    設置設備名稱

sw1(config)#ip domain-name test.com                添加域名名稱

sw1(config)#ip ssh time-out 30                        超時時間爲30秒

sw1(config)#ip ssh version 2                       啓用SSH版本2

sw1(config)#ip ssh authentication-retries 2               允許連接嘗試次數

sw1(config)#crypto key generate rsa                    生成密鑰

The name for the keys will be: sw1.test.com

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 minutes.

 

How many bits in the modulus [512]: 1024             設置密鑰長度

% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

 

sw1(config)#user

*?? 4 23:57:37.321: %SSH-5-ENABLED: SSH 1.99 has been enabled

sw1(config)#username admin password 123456     添加用戶和密碼

sw1(config)#line vty 0 4             開啓vty遠程

sw1(config-line)#login local              設置只允許本地用戶訪問

sw1(config-line)#transport input ssh         設置允許SSH訪問

sw1(config-line)#transport output telnet      設置允許telnet其他設備

sw1(config-line)#exit

 

 

驗證:

image.png

 

ps:

Router(config)#security passwords min-length  8

     # 設置登入enable、用戶密碼的最短長度爲8位,範圍(0- -16)

<0-16> Minimum length of all user/enable passwords

Router(config)#login block-for 60 attempts 3 within 30 

            # 30秒內輸錯3次密碼將等待60秒後才能再次登入

 

Router(config)#login on-failure log     # 將登入失敗的信息記錄在log中

Router(config)#login on-success log     # 將登入成功的信息記錄在log中

 

 

 3.   使用AAA方式認證登入

 

R1(config)#aaa new-model  # 啓用AAA認證

 

R2(config)#aaa authentication ?                

enable    Set authentication lists for enable

               #對使用enable命令進入特權模式時進行認證

login     Set authentication lists for logins.  

              #當有登入連接時進行認證

ppp       Set authentication lists for ppp.

                 #對基於PPP協議的一些網絡應用進行認證

 

格式: aaa authentication  動作 列表名 認證類型

 

R2(config)#aaa authentication login test  local  # 使用本地數據庫認證

R2(config)#enable secret 12345           # 特權密碼

R2(config)#username qq privilege 15 secret 5 1234 # 創建本地用戶

R2(config)#line vty 0 1                  # 使用0 1虛擬遠程

R2(config-line)#login authentication test      # 啓用test 認證

 

R2#show aaa local user lockout           #查看被鎖定用戶命令

Local-user Lock time

admin 00:14:40 UTC ?? ?? 01 1993

admin 00:14:40 UTC ?? ?? 01

 

R2#clear aaa local user lockout username admin   #清除鎖定用戶命令

 

 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章