天天看點

使用者通路和權限管理

1.設定使用者名和密碼

提問:為每個單獨的人員設定不同的使用者名和密碼

回答:

Router1(config)#username NAME password WORD

Router1(config)#username NAME nopassword  //建立username不使用密碼

Router1(config)#aaa new-model

Router1(config)#aaa authentication login local_auth local

Router1(config)#line vty 0 4

Router1(config-line)#login authentication local_auth

注釋:

  • 不推薦使用沒有密碼的username,會産生安全問題
  • 設定單獨的使用者名和密碼在日志中會顯示誰做了修改,比如%SYS-5-RELOAD: Reload requested by kdooley on vty0 (172.25.1.1)
  • 在username這個指令裡面還有一個autocommand的選項,實作登入以後自動執行某個特定的指令的作用,然後自動推出。下面的例子就是一個使用者名為NAME 無密碼,登入以後顯示完端口狀态就自動退出的例子

    Router1(config)#aaa authentication login default local

    Router1(config)#aaa authorization exec default local

    Router1(config)#username NAME nopassword noescape

    Router1(config)#username NAME autocommand show ip interface brief

    這裡的noescape防止使用者使用escape來進入路由器的EXEC模式,強烈推薦使用

2.加密密碼

提問:加密密碼進而在配置檔案中不明文顯示

Router1(config)#enable password oreilly

Router1(config-line)#password cookbook

Router1(config-line)#line con 0

Router1(config-line)#line aux 0

Router1(config)#service password-encryption

  • 這種加密方式很弱,很容易被破解

3.一種更好的密碼加密技術

提問:使用強度高的加密方式而不是思科預設的加密技術

Router1(config)#enable secret ORAbooks

在IOS 12.2(8)T後也可以對username的密碼做高強度的加密

Router1(config)#username ijbrown secret oreilly

注釋:

  • 由于這種加密方式使用的是MD5是以破解難度相對增大了
  • 密碼設定正常沒有?,不過可以通過Control v+?的方式來輸入

4. 移去配置檔案中的密碼資訊

提問:不想在配置檔案中顯示密碼

回答:使用腳本略去

  • 簡單的用show tech指令也可以

5.解密思科的弱密碼

提問:破解思科預設的密碼算法

  • 可以使用BOSON網站上的免費工具

6.顯示目前登入使用者

提問:顯示目前登入裝置的使用者

回答:

Router1#show users(who)

  • Router1#show users all 顯示所有登入裝置的使用者線程
  • finger @Router1 遠端檢視登入使用者

7.發資訊給其它使用者

提問:試圖發送資訊給登入在同一裝置的其它使用者

Router1#send *

Router1#send console 0

Router1#send vty 2

Router1#send 66

  • 很好用的特性,比如當你重新開機的時候需要告訴别人,文本資訊^+Z結束

8.修改可用VTY數目

提問:增加或者減少可登入使用者的數目

Router1(config)#line vty 0 9

  • 預設可登入vty數目為5(0-4),不能删除
  • 對于增加的VTY線程可以使用no line vty x(x>4) 删除
  • 不能單獨添加vty線程,若line vty 9,則自動建立vty 5-9
  • 同樣不能删除單獨的vty線程,若no line vty 9,則自動删除vty 5-9

9.修改VTY的逾時時長

提問:修改逾時避免使用者登入逾時被系統斷開

Router1(config-line)#exec-timeout 0 0 (exec-timeout 240 0)

  • 預設情況下使用者10分鐘空閑就會被踢掉系統,0 0可以永不逾時,第一個0是分鐘,最長35791分鐘(24天),第二個0是秒
  • 同時為了防止有些使用者掉死但是還占用vty端口的情況,建議使用下面指令來防止:
  • Router1(config)#service tcp-keepalives-in //保證Tcp建立的入連結是活動的,如果路由器或交換機沒有收到遠端系統的響應,會自動關閉連接配接
  • 使用show terminal指令檢視目前線程的不活動時間

10.限制使用者登入可以使用的協定

提問:隻允許使用者用特定的協定來進行系統登入

Router1(config-line)#transport input telnet

  • 預設情況下除了可以telnet登入,還支援以下協定登入lat,pad,v120,lapb-ta,rlogin,ssh

11.配置使用者登入可用總時長

提問:對使用者登入總時長進行限制,不論是否在空閑還是活動

Router1(config-line)#absolute-timeout 5

Router1(config-line)#logout-warning 30

  • 建議登出警告不小于10分鐘

12.部署警示性資訊

提問:設定登入時顯示的警示性資訊

Router1(config)#banner exec  # This is an exec banner #

Router1(config)#banner login # This is a login banner #

Router1(config)#banner motd  $ This is a motd banner $

  • Motd為Message of the Day,每天的資訊,很少使用
  • Login banners主要用來顯示一個安全警告
  • 一個好的登入警告應該包括下面幾點:

    1.告訴企圖登入的人,沒有經過授權使用本路由器是不允許的

    2.告訴企圖登入的人,所有的操作都是被監控的

    3.告訴企圖登入的人,沒進過授權的操作是不合法的,這些記錄将會被用來進行法律行動

    4.最重要的是,登入警告中,不能透露有關路由器的敏感的資訊為黑客提供友善

下面是一個FBI的路由器登入banner做參考:

Router1(config)#banner login #

Enter TEXT message.    End with the character '#'.

+--------------------------------------------------------------------+

|                                WARNING                             |

|                                -------                             |

| This system is solely for the use of authorized users for official |

| purposes.    You have no expectation of privacy in its use and to  |

| ensure that the system is functioning properly, individuals using  |

| this computer system are subject to having all of their activities |

| monitored and recorded by system personnel. Use of this system     |

| evidences an express consent to such monitoring and agreement that |

| if such monitoring reveals evidence of possible abuse or criminal  |

| activity, system personnel may provide the results of such         |

| monitoring to appropriate officials.                               |

#

Router1(config)#end

13.在特定端口禁用Banners顯示

提問:aux口用于modem連接配接,為了避免出現問題希望關閉banner顯示

回答

Router1(config)#line aux 0    

Router1(config-line)#no motd-banner

Router1(config-line)#no exec-banner

  • 不能線上程上關閉login banner,是以如果你要達到這個目的,你可以使用motd banner代替login banner

14.禁用Line登入

提問:禁止在AUX或者Line端口進行裝置登入

禁止在AUX進行裝置登入

Router1(config)#line aux 0

Router1(config-line)#transport input none

Router1(config-line)#no exec

Router1(config-line)#exec-timeout 0 1

Router1(config-line)#no password

Router1(config-line)#exit

禁止在Line端口進行裝置登入

Router1(config)#access-list 98 deny any log

  • transport input none 指令阻止反向TELNET到這個網絡

    no exec 指令阻止端口運作EXEC模式會話

    no password 強制路由器清除線程上的密碼,使用者即使連接配接了也不能進行認證

  • 從console口來恢複密碼很容易,是以推薦将路由器放在安全的地方,實體安全很重要
  • 你可以使用本地認證(local authentication)或AAA來代替直接線上程下配置密碼

15.為管理者保留特定的登入端口

提問:防止所有的登入端口都被占用,為管理者留一個後門

你可以為你自己保留一個VTY端口來登入路由器

Router1(config)#access-list 9 permit 172.25.1.1

Router1(config)#line vty 4

Router1(config-line)#access-class 9 in

或者使用rotary指令更改telnet登入的端口,來增加安全性

Router1(config)#line vty 5 7

Router1(config-line)#rotary 25

  • 在使用第二種rotary指令時就相應的改變登入時的端口号碼,不是預設的23,而是3000+rotary的号碼25=3025
  • 可以使用show line vty 來檢視rotary和access-class相關資訊

16.限制特定位址的Telnet登入 

提問:隻允許特定的機器進行Telnet登入

Router1(config)#access-list 99 permit 172.25.1.0 0.0.0.255

Router1(config)#access-list 99 deny any log              

Router1(config-line)#access-class 99 in

  • 推薦使用access-class來保證隻有授權使用者才能通過VTY來通路路由器

17.對Telnet通路進行日志記錄

提問:記錄每次telnet的日志

Router1(config)#access-list 90 permit any log

Router1(config-line)#access-class 90 in

  • 需要注意的是不管登入成功還是失敗,在日志中都是顯示的permitted

    %SEC-6-IPACCESSLOGS: list 90 permitted 172.25.1.1 1 packet

18.設定發起Telnet的源位址

提問:有時對端裝置有安全設定隻允許特定的位址對外發起telnet請求

設定為對外發起的TELNET設定一個統一的IP源位址

Router1(config)#ip telnet source-interface loopback0

或者為某一個特定的telnet目的設定IP源位址

Router1#telnet 172.25.1.5 /source-interface loopback0

  • 預設情況路由器會使用到目的地的端口來做Telnet的源位址

19.自動登入

  • 使用腳本略去,其實用SecueCRT很容易設定

20.使用SSH登入

提問:啟用SSH這種加密的登入方式

Router1(config)#hostname Router1

Router1(config)#ip domain-name neoshi.net

Router1(config)#crypto key generate rsa

The name for the keys will be: Router1.oreilly.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 RSA keys ...

[OK]

Router1(config)#

Jun 27 15:04:15: %SSH-5-ENABLED: SSH 1.5 has been enabled

Router1(config)#ip ssh time-out 120

Router1(config)#ip ssh authentication-retries 4

  • 配置步驟:

    1.确認你運作的IOS版本大于12.1(1)T

    2.确認你運作的IOS版本包含IPSec特性(DES或3DES,最好3DES)

    3.配置本地認證(local authentication)或AAA,SSH不支援預設VTY密碼加密

    4.配置路由器名,不能為Router

    5.用ip domain-name NAME指令在路由器上配置域名

    6.用crypto key negerate rsa指令産生一個SSH主機密鑰,密鑰長度從360 bits到2048 bits,密鑰越長越安全,但影響路由器性能,不推薦使用短于1024 bits的密碼。

  • 可以使用crypto key zeroize rsa指令删除密鑰
  • 建立一個密鑰會自動啟用SSH協定,當你第一次登入啟用SSH的路由器,SSH用戶端會要求儲存使用者的密鑰
  • 從IOS 12.3(4)T開始支援SSH v2(ip ssh version 2),之前隻支援v1
  • 從IOS 12.1(3)T開始Cisco路由器支援SSH用戶端指令,可以用來登入其他SSH伺服器
  • 可以使用show ip ssh指令檢視SSH伺服器相關資訊

21.改變IOS指令的特權等級

提問:修改特定IOS指令的特權等級

Router1(config)#privilege exec level 1 show startup-config

  • 預設情況路由器支援16種特權等級,指令一般歸屬于0,1和15三種特權等級
  • 在特權等級0下面隻支援disable, enable, exit, help, 和logout指令

    在特權等級1下面不能對配置進行修改

  • 進入特權等級15:enable,進入特權等級1:disable
  • enable(0-15)進入比目前高的特權等級

    disable(0-15)進入比目前低的特權等級

  • telnet的預設等級是特權等級1
  • 用高特權等級設定的指令,在低特權等級下便不能使用,如:

    privilege exec level 15 show ip route,則在特權0下連show指令也不能使用,除非輸入:

    privilege exec level 1 show (ip)

  • Router1(config)#privilege exec reset show startup-config将指令重置到預設設定

22.基于使用者的特權等級Defining Per User Privileges

提問:給不同的使用者賦予不同的特權等級

Router1(config)#username NAME privilege 10 password password

Router1(config)#privilege exec level 10 show ip route

Router1(config)#privilege exec level 1 show ip      

Router1(config)#privilege exec level 1 show  

  • 若給帳戶指定特權等級,則當使用者登入後,直接進入該特權等級,而不用輸入enable
  • 通常的0,1和15三種等級彈性不足,可以定義更多的等級給不同的使用者

23. 基于端口的特權等級

提問:根據登入的不同端口自動賦予特定的特權等級

Router1(config-line)#privilege level 5

Router1(config)#privilege exec level 5 show ip route

Router1(config)#privilege exec level 1 show ip     

  • 預設情況下,從端口登入,特權等級都是1
  • 當該端口指定特權等級後,從該端口登入,則直接進入該特權等級

繼續閱讀