跳转到主内容
websoft网络软件专家 - 深耕网络技术,打造实用软件!

关于SQLNET.AUTHENTICATION_SERVICES验证方式的说明

今天去客户那里巡检,客户提出为了提高数据库安全性考虑,需要修改sys/system密码,并通过数据库验证方式来取代默认的操作系统方式,现在我来把这两种验证方式总结一下。 操作系统验证,即通过操作系统账户的权限访问数据库,举个例子,如果已经拥有了windows今天去客户那里巡检,客户提出为了提高数据库安全性考虑,需要修改sys/system密码,并通过数据库验证方式来取代默认的操作系统方式,现在我来把这两种验证方式总结一下。

操作系统验证,即通过操作系统账户的权限访问数据库,举个例子,如果已经拥有了windows下的系统管理员administrator的权限,那么当采用该方式验证的话,无需输入用户/密码就可以访问,比如:sqlplus / as sysdba;哪怕是任意输入的用户名和密码,也无所谓,比如:sqlplus abc/efg as sysdba;C:\Documents and Settings\Administrator>sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:02:25 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> exit从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options 断开C:\Documents and Settings\Administrator>sqlplus abc/efg as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:02:33 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved.

连接到:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL>当然,这仅限于sys用户,对于其他用户,哪怕是system,也是必须输入用户名和密码才能访问数据库的C:\Documents and Settings\Administrator>sqlplus system/123456 SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:05:07 2014 Copyright (c) 1982, 2005, Oracle. All rights reserved.

ERROR:ORA-01017: 用户名/口令无效; 登录被拒绝请输入用户名:我的环境中,默认sys和system用户的密码都是"oracle",数据库sys用户的密码,是存放在PWD.ora中的(Unix/Linux中为oraPW),想知道sys用户是否有密码,可以通过以下语句查询:SQL> select * from v$pwfile_users;USERNAME SYSDB SYSOP------------------------------ ----- -----SYS TRUE TRUE显然,对于采用操作系统验证来访问数据库,安全性还是有一定隐患的,通常在大公司,SA和DBA都是分权管理的,如果数据库因为采用了操作系统验证方式,而使SA可以随意访问数据库那也是不太合适的。基于这种场景,那么我们就可以采用数据库验证方式来限制sys用户必须输入正确的用户名和密码才能够访问数据库。这样的话,当SA没有DBA的sys密码,就无法访问数据库了。在windows中,是通过sqlnet.ora这个文件来实现验证机制控制的,当你装完数据库并用netca创建了监听,就会生成这个文件,通常默认是以下内容:# This file is actually generated by netca. But if customers choose to# install "Software Only", this file won't exist and without the native# authentication, they will not be able to connect to the database on NT.SQLNET.AUTHENTICATION_SERVICES = (NTS)也就是说,默认就是采用操作系统验证的,也许oracle认为,拥有了sa权限,就拥有了系统最高权限,所以数据库dba的sys用户也无需再验证密码了如果设置成(NONE),就表示采用数据库身份验证,还可以设置成(NONE,NTS),其实这样设也没有意义了,只要括号中有NTS,就会采用操作系统验证,NONE就没有用了这里要指出一点,有些文章中说还可以设置成(ALL),但我设计测试下来,如果设置成(ALL),会提示ERROR:C:\Documents and Settings\Administrator>sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:26:06 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.ERROR:ORA-12641: 验证服务无法初始化请输入用户名:如,以下这段描述:Use the parameter SQLNET.AUTHENTICATION_SERVICES to enable one or more authentication services.If authentication has been installed,it is recommended that this parameter be set to either none or to one of the authentication methods.NONE for no authentication methods. A valid username and password can be used to access the database.ALL for all authentication methodsNTS for Windows NT native authentication(An authentication method that enablesa client single login access to a Windows NT server and a database running on the server)虽然这里说到了有ALL,不过我亲自测试过,确实不行,也许和版本有关,我的版本是10.2.0.1 windows 32bit的--修改为(NONE)后登陆C:\Documents and Settings\Administrator>sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:50:49 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.ERROR:ORA-01031: 权限不足请输入用户名: sys as sysdba输入口令: --此处输入正确的密码“oracle”连接到:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL>--断开连接,把(NONE)改为(NTS)直接连接SQL> disc从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining options 断开SQL> conn abc/123 as sysdbaERROR:ORA-01031: 权限不足由于没有退出SQLPLUS,刚才改的(NTS)还未生效,可见sqlnet.ora文件是在进入SQLPLUS时才去读取的--仍然保持(NTS),退出SQLPLUS后重新登陆SQL> exitC:\Documents and Settings\Administrator>sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:54:52 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.连接到:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL>现在又是操作系统验证了注意,如果改成(NONE)以后,当使用RMAN时,system用户就不能操作了,输入正确的密码也不行,只有sys用户并输入密码才可以,测试如下:--设置为(NTS)的时候登陆RMANC:\Documents and Settings\Administrator>rman target /恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:07 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.连接到目标数据库: ORCL10G (DBID=1041171241248)RMAN> exit恢复管理器完成。C:\Documents and Settings\Administrator>rman target system/oracle恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:33 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.连接到目标数据库: ORCL10G (DBID=1041171241248)RMAN> exit恢复管理器完成。--修改为(NONE)后,再用密码登陆一次RMANC:\Documents and Settings\Administrator>rman target system/oracle --注意,这里密码是正确的恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:06 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-00554: 内部恢复管理器程序包初始化失败RMAN-04005: 目标数据库中存在错误:ORA-01031: 权限不足C:\Documents and Settings\Administrator>rman target /恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:08:47 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-00554: 内部恢复管理器程序包初始化失败RMAN-04005: 目标数据库中存在错误:ORA-01031: 权限不足C:\Documents and Settings\Administrator>rman target sys/oracle恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:16 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.连接到目标数据库: ORCL10G (DBID=1041171241248)RMAN>很显然,在采用数据库身份验证以后,system用户被禁止使用RMAN了,只有拥有数据库最高权限的sys用户,才能登陆RMAN,而且必须是输入密码的方式登陆总结:在windows下,SQLNET.AUTHENTICATION_SERVICES必须设置为NTS才能使用OS认证,不设置(如,把该行语句加#注释符号)或者设置为其他任何值都不能使用OS认证。主要是以下几种情况:1. sqlnet.ora文件为空,或用#注释掉 --基于Oracle密码文件验证2. SQLNET.AUTHENTICATION_SERVICES = (NTS) --基于操作系统验证3. SQLNET.AUTHENTICATION_SERVICES = (NONE) --基于Oracle密码文件验证4. SQLNET.AUTHENTICATION_SERVICES = (NONE,NTS) --基于操作系统验证(前后顺序颠倒也一样)注意:默认情况下,Unix/Linux下的sqlnet.ora文件是没有SQLNET.AUTHENTICATION_SERVICES参数的,似乎连sqlnet.ora这个文件也没有,这和windows有很大的不同此时是操作系统验证和Oracle密码验证并存,如果加上SQLNET.AUTHENTICATION_SERVICES这个参数后,不管是设置为(NONE)、(NTS)或(NONE,NTS),都是基于Oracle密码验证。

相关文章