Juniper SRX (Junos OS) 建立自訂的帳戶類別(login class)


Juniper SRX (Junos OS) 建立自訂的帳戶類別(login class)

為何我們需要建立自訂的帳戶類別(login class)?
我們可以從下列之訊息來了解:
root@srx210# set system login user admin class ?
Possible completions:
  <class>              Login class
  operator             permissions [ clear network reset trace view ]
  read-only            permissions [ view ]
  super-user           permissions [ all ]
  unauthorized         permissions [ none ]
[edit]

root@srx210#

我們可以看到預設的帳戶類別只有四種,且權限太少不敷使用。
所以我們需要自訂新的帳戶類別才能符合我們的需求,如下:

login {
    /*這類用戶只能查看統計和配置。 他們不允許修改任何配置。 */
    class viewers {
        idle-timeout 5;
        permissions [ configure firewall interface network routing snmp system trace view];
    }
    /*這類用戶可以查看和修改配置。 */
    class operators {
        idle-timeout 5;
        permissions [admin clear configure interface interface-control network reset routing routing-control snmp snmp-control trace-control firewall-control rollback];
    }
    /*這類用戶有無限的訪問和控制。 */
    class administrators {
        idle-timeout 5;
        permissions all;
    }
}

login {
    /* 這是本地超級用戶帳戶。 如果RADIUS驗證伺服器故障或無法訪問,請恢復使用路由器上的本地帳戶。 */
    user admin {
        uid 1000;
        class administrators;
        authentication {
            ssh-dsa “XXXXXXXXXXXXX”; # Secure shell (ssh) RSA public key string
        }
    }
    /* 以下為三種帳戶類別樣版的使用範例。 */
    user user-viewers {
        uid 1001;
        class viewers;
    }
    user user-operators {
        uid 1002;
        class operators;
    }
    user user-admin {
        uid 1003;
        class administrators;
    }

}


下列為上述之CLI命令,如下:
set system login class administrators idle-timeout 5
set system login class administrators permissions all
set system login class operators idle-timeout 5
set system login class operators permissions admin
set system login class operators permissions clear
set system login class operators permissions configure
set system login class operators permissions firewall-control
set system login class operators permissions interface
set system login class operators permissions interface-control
set system login class operators permissions network
set system login class operators permissions reset
set system login class operators permissions rollback
set system login class operators permissions routing
set system login class operators permissions routing-control
set system login class operators permissions snmp
set system login class operators permissions snmp-control
set system login class operators permissions trace-control
set system login class viewers idle-timeout 5
set system login class viewers permissions configure
set system login class viewers permissions firewall
set system login class viewers permissions interface
set system login class viewers permissions network
set system login class viewers permissions routing
set system login class viewers permissions snmp
set system login class viewers permissions system
set system login class viewers permissions trace
set system login class viewers permissions view
set system login user user-admin uid 1003
set system login user user-admin class administrators
set system login user user-operators uid 1002
set system login user user-operators class operators
set system login user user-viewers uid 1001
set system login user user-viewers class viewers


Juniper SRX服務網關必須確保啟動UNIXshell的訪問僅限於root帳戶。
限制創建UNIXshell的權限限制了對這個強大功能的訪問。 系統管理員無論其他權限如何,都需要知道此訪問的root密碼,從而限制惡意或意外規避安全控制的可能性。
驗證每個login class是否配置為拒絕訪問UNIX shell
[edit]
show system login
shell, maintenance, all,

If each configured login class is not configured to deny access to the UNIX shell, this is a finding.

將以下命令添加到每個登錄類login class中。
set system login class administrators deny-commands "start shell"
set system login class operators deny-commands "start shell"
set system login class viewers deny-commands "start shell"

root@srx210# set system login user admin class ?   //我們可以看到多出三個自訂類別
Possible completions:
  <class>              Login class
  administrators
  operator             permissions [ clear network reset trace view ]
  operators
  read-only            permissions [ view ]
  super-user           permissions [ all ]
  unauthorized         permissions [ none ]
  viewers
[edit]

root@srx210#


了解管理角色Administrative Roles
系統用戶可以是允許用戶充當系統的特定管理員的類的成員。
要求查看或修改項目的特定角色限制了用戶可以從系統獲得的信息範圍。
它還限制了系統對用戶有意或無意的修改或觀察開放的程度。
我們建議您在設計管理角色時使用以下準則:
    不允許任何用戶以root身份登錄系統。
    將每個用戶限制為執行用戶職責所需的最小權限集。
    不允許任何用戶屬於包含shell權限標誌的登錄類。 shell權限標誌允許用戶從CLI運行啟動shell命令。
    允許用戶擁有回滾權限。回滾權限允許用戶撤消由管理員執行的操作,但不允許他們提交更改。

您可以通過將登錄類配置為具有該角色所需的權限來為用戶分配管理角色。您可以配置每個類以允許或拒絕按名稱訪問配置語句和命令。這些特定的限制覆蓋並優先於在該類中也配置的任何權限標誌。您可以將以下某個角色屬性分配給管理用戶。
    加密管理員Crypto-administrator - 允許用戶配置和監視加密數據。
    安全管理員Security-administrator - 允許用戶配置和監控安全數據。
    審計管理員Audit-administrator - 允許用戶配置和監視審計數據。
    入侵偵測管理員IDS-administrator - 允許用戶監視和清除入侵檢測服務(IDS - intrusion detection service)安全日誌。

您需要在為這些管理角色創建的類中設置security-role屬性。此屬性限制哪些用戶可以顯示和清除安全日誌,這些操作不能通過配置單獨執行。
例如,如果要限制清除並向IDS管理員角色顯示IDS日誌,則需要在為IDS管理員角色創建的ids-admin類中設置security-role屬性。同樣,您需要將安全角色設置為其他管理員值之一,以限制該類無法清除並僅顯示非IDS日誌。

注意:當用戶刪除現有配置時,已刪除配置(即,用戶無權修改的子對象)的層次結構下的配置語句現在保留在設備中。

關於login class operators security-role的相關說明請參考下列之原廠連結:




配置基於時間的用戶訪問Configuring Time-Based User Access

我們可以在用戶登入類別中指定用戶可以在一個星期的哪幾天登入系統。
[edit system]
login {
    class class-name {
        allowed-days [ days-of-the-week ];   /* [ monday tuesday wednesday thursday friday saturday sunday ] */
    }
}

我們可以在用戶登入類別中指定用戶可以在一天的哪個時段登入系統。
[edit system]
login {
    class class-name {
        access-start HH:MM;
        access-end HH:MM;
    }
}

我們可以在用戶登入類別中指定用戶可以在一個星期的哪幾天中的哪個時段來登入系統。
[edit system]
login {
    class class-name {
        allowed-days [ days-of-the-week ];
        access-start HH:MM;
        access-end HH:MM;
    }
}

下面為設定範例。
[edit system]
login {
    class operator-day-shift {
        allowed-days [ monday wednesday friday ];
        access-start 0830;
        access-end 1630;
    }

}



配置本地管理員帳戶 Local Administrator Account
超級用戶權限授予用戶在路由器上使用任何命令的權限,並且通常為特定少數用戶(例如係統管理員)預留。 使用密碼保護本地管理員帳戶非常重要,以防止未經授權的用戶訪問可用於更改系統配置的超級用戶命令。 即使使用RADIUS身份驗證的用戶也應配置本地密碼。 如果RADIUS失敗或無法訪問,登錄過程將恢復為本地管理員帳戶的密碼驗證。

[edit]
system {
    login {
        user admin {
            uid 1000;
            class superuser;
            authentication {
                encrypted-password "<PASSWORD>"; # SECRET-DATA
            }
        }
    }

}



root@srx100-a# set system login class operators ?
Possible completions:
  access-end           End time for remote access (hh:mm)
  access-start         Start time for remote access (hh:mm)
  allow-commands       Regular expression for commands to allow explicitly
  allow-configuration  Regular expression for configure to allow explicitly
+ allow-configuration-regexps  Object path regular expressions to allow
+ allowed-days         Day(s) of week when access is allowed.
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
  deny-commands        Regular expression for commands to deny explicitly
  deny-configuration   Regular expression for configure to deny explicitly
+ deny-configuration-regexps  Object path regular expressions to deny
  idle-timeout         Maximum idle time before logout (minutes)
  login-alarms         Display system alarms when logging in
  login-script         Execute this login-script when logging in
  login-tip            Display tip when logging in
+ permissions          Set of permitted operation categories
  security-role        Common Criteria security role
[edit]
root@srx100-a# set system login class operators security-role ?
Possible completions:
  audit-administrator  Audit administrator
  crypto-administrator  Cryptographic administrator
  ids-administrator    IDS administrator
  security-administrator  Security administrator
[edit]

root@srx100-a#


下列為所有可用的權限選項示範:
set system login class CLI-ALL permissions access
set system login class CLI-ALL permissions access-control
set system login class CLI-ALL permissions admin
set system login class CLI-ALL permissions admin-control
set system login class CLI-ALL permissions clear
set system login class CLI-ALL permissions configure
set system login class CLI-ALL permissions control
set system login class CLI-ALL permissions field
set system login class CLI-ALL permissions firewall
set system login class CLI-ALL permissions firewall-control
set system login class CLI-ALL permissions floppy
set system login class CLI-ALL permissions flow-tap
set system login class CLI-ALL permissions flow-tap-control
set system login class CLI-ALL permissions idp-profiler-operation
set system login class CLI-ALL permissions interface
set system login class CLI-ALL permissions interface-control
set system login class CLI-ALL permissions maintenance
set system login class CLI-ALL permissions network
set system login class CLI-ALL permissions pgcp-session-mirroring
set system login class CLI-ALL permissions pgcp-session-mirroring-control
set system login class CLI-ALL permissions reset
set system login class CLI-ALL permissions rollback
set system login class CLI-ALL permissions routing
set system login class CLI-ALL permissions routing-control
set system login class CLI-ALL permissions secret
set system login class CLI-ALL permissions secret-control
set system login class CLI-ALL permissions security
set system login class CLI-ALL permissions security-control
set system login class CLI-ALL permissions shell
set system login class CLI-ALL permissions snmp
set system login class CLI-ALL permissions snmp-control
set system login class CLI-ALL permissions system
set system login class CLI-ALL permissions system-control
set system login class CLI-ALL permissions trace
set system login class CLI-ALL permissions trace-control
set system login class CLI-ALL permissions view

root@srx100# run show cli authorization | no-more
Current user: 'root        ' class 'super-user'
Permissions:
    admin       -- Can view user accounts
    admin-control-- Can modify user accounts
    clear       -- Can clear learned network info
    control     -- Can modify any config
    edit        -- Can edit full files
    field       -- Can use field debug commands
    floppy      -- Can read and write the floppy
    interface   -- Can view interface configuration
    interface-control-- Can modify interface configuration
    network     -- Can access the network
    reset       -- Can reset/restart interfaces and daemons
    routing     -- Can view routing configuration
    routing-control-- Can modify routing configuration
    shell       -- Can start a local shell
    snmp        -- Can view SNMP configuration
    snmp-control-- Can modify SNMP configuration
    system      -- Can view system configuration
    system-control-- Can modify system configuration
    trace       -- Can view trace file settings
    trace-control-- Can modify trace file settings
    view        -- Can view current values and statistics
    maintenance -- Can become the super-user
    firewall    -- Can view firewall configuration
    firewall-control-- Can modify firewall configuration
    secret      -- Can view secret statements
    secret-control-- Can modify secret statements
    rollback    -- Can rollback to previous configurations
    security    -- Can view security configuration
    security-control-- Can modify security configuration
    access      -- Can view access configuration
    access-control-- Can modify access configuration
    view-configuration-- Can view all configuration (not including secrets)
    flow-tap    -- Can view flow-tap configuration
    flow-tap-control-- Can modify flow-tap configuration
    idp-profiler-operation-- Can Profiler data
    pgcp-session-mirroring-- Can view pgcp session mirroring configuration
    pgcp-session-mirroring-control-- Can modify pgcp session mirroring configuration
    storage     -- Can view fibre channel storage protocol configuration
    storage-control-- Can modify fibre channel storage protocol configuration
    all-control -- Can modify any configuration Individual command authorization:
    Allow regular expression: none
    Deny regular expression: none
    Allow configuration regular expression: none
    Deny configuration regular expression: none
[edit]

root@srx100#



關於每個權限的作用及可執行的CLI命令,請自行參考下列之網路連結:
用戶訪問權限的權限旗標Permission Flags for User Access Privileges



root@srx210> show system login lockout
User accounts not locked

root@srx210> clear system login lockout all
root@srx210> clear system login lockout user admin
root@srx100> clear system login lockout ?
Possible completions:
  all                  Clear login locks on all user acounts
  user                 Name of user
root@srx100>

root@srx210# set system login class super-user-local security-role ?
Possible completions:
  audit-administrator  Audit administrator
  crypto-administrator  Cryptographic administrator
  ids-administrator    IDS administrator
  security-administrator  Security administrator
[edit]
root@srx210#


    login {
        retry-options {
            tries-before-disconnect 10;
            backoff-threshold 3;
            backoff-factor 5;
            minimum-time 30;
            maximum-time 60;
            lockout-period 30;
        }
        class super-user-local {
            permissions all;
            deny-commands "start shell";
            security-role audit-administrator;
        }
        user admin {
            uid 2002;
            class super-user;
            authentication {
                encrypted-password "$1$/kEYr1te$1jXrS/VuKbRtcjsPsxgPp/";
            }
        }
        user charlie {
            uid 2000;
            class super-user-local;
            authentication {
                encrypted-password "$1$XzgnKCCe$.G.oEnvNwI.Ad7aX.wup60";
            }
        }

    }



這個網誌中的熱門文章

如何測試網路連線--網路斷線了怎麼辦?

筆記電腦刷BIOS失敗無法開機—用CH341A編程器重刷BIOS教學!

INTEL XTU使用教學以及對筆電應具備的XTU設定概念