Oracle 體系結構(25)—— Oracle 生産庫的安全設定(使用者及使用者權限管理)
一、賬戶管理
1、按照使用者配置設定賬号
create user user01 identified by password1;
create user user02 identified by password2;
....
create user usern identified by passwordn;
建立角色(role),并給角色授權,把 role 付給不同的賬号。
2、删除無用賬号
删除或鎖定與資料庫運作、維護等無關的賬号。
alter user user_name account lock;
drop user user_name cascade;
3、限制 dba 使用者遠端登入
限制具備超級管理(sysdba)權限的使用者遠端登入。
(1)設定初始化參數 remote_login_passwordfile=none,禁止 sysdba 使用者遠端登入
--設定初始化參數 remote_login_passwordfile=none,禁止 sysdba 使用者遠端登入。
SQL> show parameter remote_login_passwordfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
SQL> alter system set remote_login_passwordfile=none scope=spfile sid='*';
System altered.
--重新開機資料庫
--檢視初始化參數 remote_login_passwordfile 的取值
SQL> show parameter remote_login_passwordfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
remote_login_passwordfile string NONE
(2)在 sqlnet.ora 中設定 SQLNET.AUTHENTICATION_SERVICES=NONE 禁止 sysdba 角色的自動登入
[[email protected] ~]$ cd $ORACLE_HOME/network/admin
[[email protected] admin]$ ll
total 28
-rw-r--r-- 1 grid oinstall 181 Aug 27 01:06 endpoints_listener.ora
-rw-r--r-- 1 grid oinstall 181 Aug 27 00:55 endpoints_listener.ora.bak.rac2
-rw-r--r-- 1 grid oinstall 718 Aug 27 00:55 listener.ora
-rw-r--r-- 1 grid oinstall 718 Aug 5 03:56 listener.ora.bak.rac2
drwxr-xr-x 2 grid oinstall 4096 Apr 21 15:39 samples
-rw-r--r-- 1 grid oinstall 381 Apr 21 15:39 shrept.lst
-rw-r--r-- 1 grid oinstall 212 Apr 21 16:02 sqlnet.ora
[[email protected] admin]$ vi sqlnet.ora
# sqlnet.ora.rac2 Network Configuration File: /u01/app/11.2.0/grid/network/admin/sqlnet.ora.rac2
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ADR_BASE = /u01/app/grid
SQLNET.AUTHENTICATION_SERVICES=NONE
4、使用者最小權限原則
根據業務需要,為使用者配置所需的最小權限。
--為使用者賦予最小權限
grant 權限 to user_name;
--收回使用者的多餘權限
revoke 權限 from user_name;
5、使用角色(role)管理使用者權限
--建立角色
create role role_name....
grant role_name, role_name,... to user_name;
6、配置使用者資源檔案
通過使用者的資源檔案對使用者的屬性進行控制,比如密碼政策、資源限制等。
--建立使用者資源檔案
create profile profile_name limit
FAILED_LOGIN_ATTEMPTS 6
PASSWORD_LIFE_TIME 60
PASSWORD_REUSE_TIME 60
PASSWORD_REUSE_MAX 5
PASSWORD_VERIFY_FUNCTION VERIFY_FUNCTION
PASSWORD_LOCK_TIME 1/24
PASSWORD_GRACE_TIME 90;
--為使用者指定資源檔案
alter user user_name profile rofile_name;
7、資料字典保護
啟用資料字典保護,隻有 sysdba 使用者才能通路資料字典表。設定初始化參數 O7_DICTIONARY_ACCESSIBILITY 為 false。
SQL> show parameter o7
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY boolean FALSE
二、密碼管理
1、密碼的複雜度
為使用者建立 profile,調整 PASSWORD_VERIFY_FUNCTION 指定密碼複雜度:VERIFY_FUNCTION。密碼的長度至少 6 位,并包括數字、小寫字母、大寫字母和特殊符号四類中至少兩類。
--檢視 Oracle11g 資料庫提供的預設密碼複雜度函數腳本:Oracle安裝目錄下的 /rdbms/admin/utlpwdmg.sql 檔案
[oracle@rac1 ~]$ ls $ORACLE_HOME/rdbms/admin/utlpwdmg.sql
/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/utlpwdmg.sql
--登入 Oracle 資料庫并執行 Oracle11g 資料庫提供的預設密碼複雜度函數腳本
SQL> @?/rdbms/admin/utlpwdmg.sql
Function created.
Grant succeeded.
Profile altered.
Function created.
Grant succeeded.
--建立使用者資源檔案
SQL> create profile tom_profile limit
PASSWORD_VERIFY_FUNCTION verify_function_11G;
Profile created.
--建立使用者 tom
--建立使用者失敗,指定的密碼過于簡單
SQL> create user tom identified by "tom"
profile tom_profile;
create user tom identified by "tom"
*
ERROR at line 1:
ORA-28003: password verification for the specified password failed
ORA-20001: Password length less than 8
--重新建立使用者 tom
SQL> create user tom identified by "Tom123456"
profile tom_profile;
User created.
2、指定密碼的期限
在資源檔案中配置參數 PASSWORD_GRACE_TIME 60。指定密碼的期限為 60 天,則強制要求使用者 60 天之後必須修改密碼:
SQL> alter profile tom_profile limit
PASSWORD_VERIFY_FUNCTION verify_function_11G
PASSWORD_GRACE_TIME 60;
Profile altered.
3、設定密碼曆史
在資源檔案中配置參數 PASSWORD_REUSE_MAX 5。設定使用者不能重複使用最近 5 次(含 5 次)已經使用的密碼。
SQL> alter profile tom_profile limit
PASSWORD_VERIFY_FUNCTION verify_function_11G
PASSWORD_GRACE_TIME 60
PASSWORD_REUSE_MAX 5;
Profile altered.
4、設定使用者登入失敗 5 次後,鎖定賬号
在資源檔案中配置參數 FAILED_LOGIN_ATTEMPTS 5。當使用者連續認證失敗次數超過 5 次(不含 5次 ),鎖定賬号。
SQL> alter profile tom_profile limit
PASSWORD_VERIFY_FUNCTION verify_function_11G
PASSWORD_GRACE_TIME 60
PASSWORD_REUSE_MAX 5
FAILED_LOGIN_ATTEMPTS 5;
Profile altered.