在某些情況下可以使用REMOTE_LOGIN_PASSWORDFILE參數增強系統的安全性,所謂提高安全性就是禁止以SYSDBA或SYSOPER特權用戶從客戶端登陸到數據庫系統中。這是一種犧牲管理便捷性爲前提的。需酌情使用。
本文主要闡述REMOTE_LOGIN_PASSWORDFILE參數的三種取值及對系統的影響。
1.參考信息
官方文檔中有關REMOTE_LOGIN_PASSWORDFILE參數的描述:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams179.htm#REFRN10184
2.REMOTE_LOGIN_PASSWORDFILE參數默認值及其行爲特性分析
1)REMOTE_LOGIN_PASSWORDFILE參數的默認值是EXCLUSIVE
sys@ora10g> show parameter REMOTE_LOGIN_PASSWORDFILE
NAME TYPE VALUE
-------------------------- ---------- ----------------------
remote_login_passwordfile string EXCLUSIVE
2)嘗試將SYSDBA特權授予給普通用戶secooler
sys@ora10g> grant sysdba to secooler;
grant sysdba to secooler
*
ERROR at line 1:
ORA-01994: GRANT failed: password file missing or disabled
此處報錯是由於密碼文件丟失導致的,因爲授予sysdba權限需要調整密碼文件。
3)手工創建丟失的密碼文件
ora10g@secdb /home/oracle$ cd $ORACLE_HOME/dbs
ora10g@secdb /oracle/app/oracle/product/10.2.0/db_1/dbs$
ora10g@secdb /oracle/app/oracle/product/10.2.0/db_1/dbs$ orapwd file=orapwora10g password=oracle entries=10
4)再次嘗試SYSDBA授權成功
sys@ora10g> grant sysdba to secooler;
Grant succeeded.
5)密碼文件的變化
此時在密碼文件中記錄了這個授權的信息。
ora10g@secdb /oracle/app/oracle/product/10.2.0/db_1/dbs$ strings orapwora10g
]\[Z
ORACLE Remote Password file
INTERNAL
AB27B53EDC5FEF41
8A8F025737A9097A
SECOOLER
034E4342BB2D437D
最後兩行信息即是新增的內容。
6)客戶端連接性測試
$ sqlplus secooler/secooler@ora10g as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 21 21:48:34 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL> show user;
USER 爲 "SYS"
SQL>
注意,此處我們雖然使用的是普通用戶secooler登錄的數據庫,但真實的用戶名是SYS。因此我們便可以使用這種方法來管理數據庫,這就是便捷所在。
7)人爲移除密碼文件測試
如果此時我們將密碼文件刪除,客戶端將沒有辦法再以sysdba權限連接到數據庫
$ sqlplus secooler/secooler@ora10g as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 21 21:53:50 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
ERROR:
ORA-01031: insufficient privileges
請輸入用戶名:
因此,通過REMOTE_LOGIN_PASSWORDFILE參數和密碼文件共同實現了客戶端以SYSDBA權限登錄系統的目的。
3.REMOTE_LOGIN_PASSWORDFILE參數NONE值及其行爲特性分析
1)調整參數REMOTE_LOGIN_PASSWORDFILE爲NONE
sys@ora10g> alter system set remote_login_passwordfile=none scope=spfile;
System altered.
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ora10g> startup;
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2071640 bytes
Variable Size 125830056 bytes
Database Buffers 75497472 bytes
Redo Buffers 6316032 bytes
Database mounted.
Database opened.
sys@ora10g> show parameter REMOTE_LOGIN_PASSWORDFILE
NAME TYPE VALUE
-------------------------- ---------- ----------------------
remote_login_passwordfile string NONE
2)調整後,客戶端將無法發起連接
$ sqlplus secooler/secooler@ora10g as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 21 22:00:02 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
請輸入用戶名:
3)SYSDBA權限的授予與回收亦是被禁止的
(1)授權測試
sys@ora10g> grant sysdba to secooler;
grant sysdba to secooler
*
ERROR at line 1:
ORA-01994: GRANT failed: password file missing or disabled
注意,此處的報錯原因是不是因爲密碼文件不存在,與前面曾經提到的報錯信息有區別。
(2)回收測試
sys@ora10g> revoke sysdba from secooler;
Revoke succeeded.
此處雖然提示權限回收成功,但是實際上並沒有生效,是無效操作。證明之。
<1>在此基礎上調整參數爲EXCLUSIVE
sys@ora10g> alter system set remote_login_passwordfile=EXCLUSIVE scope=spfile;
System altered.
sys@ora10g> startup force;
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2071640 bytes
Variable Size 130024360 bytes
Database Buffers 71303168 bytes
Redo Buffers 6316032 bytes
Database mounted.
Database opened.
<2>此時客戶端依然能夠成功登陸
$ sqlplus secooler/[email protected] as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 21 22:06:05 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL>
因此證明了當REMOTE_LOGIN_PASSWORDFILE參數爲NONE時回收SYSDBA權限是無效的。
4.REMOTE_LOGIN_PASSWORDFILE參數SHARED值及其行爲特性分析
1)調整參數REMOTE_LOGIN_PASSWORDFILE爲SHARED
sys@ora10g> alter system set remote_login_passwordfile=shared scope=spfile;
System altered.
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ora10g> startup;
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2071640 bytes
Variable Size 125830056 bytes
Database Buffers 75497472 bytes
Redo Buffers 6316032 bytes
Database mounted.
Database opened.
sys@ora10g> show parameter REMOTE_LOGIN_PASSWORDFILE
NAME TYPE VALUE
-------------------------- ---------- ----------------------
remote_login_passwordfile string SHARED
2)此時客戶端的連接是不受限制的,連接通暢
$ sqlplus secooler/secooler@ora10g as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on 星期二 12月 21 22:08:04 2010
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
SQL>
3)此時服務器端授予和回收SYSDBA權限是不被允許的
sys@ora10g> grant sysdba to secooler;
grant sysdba to secooler
*
ERROR at line 1:
ORA-01999: password file cannot be updated in SHARED mode
sys@ora10g> revoke sysdba from secooler;
revoke sysdba from secooler
*
ERROR at line 1:
ORA-01999: password file cannot be updated in SHARED mode
5.小結
在此總結一下在REMOTE_LOGIN_PASSWORDFILE參數取不同值時的行爲特性。
REMOTE_LOGIN_PASSWORDFILE參數可以有三種取值:EXCLUSIVE(默認)、NONE和SHARED。
1)當取值爲EXCLUSIVE時
允許客戶端以SYSDBA或SYSOPER權限登錄到數據庫實例中完成數據庫管理操作;
允許授予和回收SYSDBA或SYSOPER權限。
2)當取值爲NONE時
禁止客戶端以SYSDBA或SYSOPER權限登錄到數據庫實例中完成數據庫管理操作;
禁止授予和回收SYSDBA或SYSOPER權限。
3)當取值爲SHARED時
允許客戶端以SYSDBA或SYSOPER權限登錄到數據庫實例中完成數據庫管理操作;
禁止授予和回收SYSDBA或SYSOPER權限。
以上便是參數REMOTE_LOGIN_PASSWORDFILE在不同取值情況下對系統的影響(本文是以SYSDBA特權爲例,SYSOPER特權相同)。每一種取值都有其自己的應用場景。我們需要做的是根據不同的場景做出相應的取捨。
本文轉自secooler的博客:http://blog.itpub.net/519536/viewspace-682282/