zoukankan      html  css  js  c++  java
  • 关于 SQLNET.AUTHENTICATION_SERVICES 验证方式的说明

    今天去客户那里巡检,客户提出为了提高数据库安全性考虑,须要改动sys/systempassword,并通过数据库验证方式来代替默认的操作系统方式,如今我来把这两种验证方式总结一下。




    操作系统验证。即通过操作系统账户的权限訪问数据库。举个样例,假设已经拥有了windows下的系统管理员administrator的权限,那么当採用该方式验证的话,无需输入用户/password就能够訪问,比方:sqlplus / as sysdba;哪怕是随意输入的username和password。也无所谓,比方:sqlplus abc/efg as sysdba;


    C:Documents and SettingsAdministrator>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 SettingsAdministrator>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,也是必须输入username和password才干訪问数据库的


    C:Documents and SettingsAdministrator>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: username/口令无效; 登录被拒绝




    请输入username:


    我的环境中。默认sys和system用户的password都是"oracle"。数据库sys用户的password,是存放在PWD<SID>.ora中的(Unix/Linux中为oraPW<SID>),想知道sys用户是否有password,能够通过下面语句查询:
    SQL> select * from v$pwfile_users;


    USERNAME                       SYSDB SYSOP
    ------------------------------ ----- -----
    SYS                            TRUE  TRUE


    显然。对于採用操作系统验证来訪问数据库,安全性还是有一定隐患的,通常在大公司,SA和DBA都是分权管理的,假设数据库由于採用了操作系统验证方式。而使SA能够任意訪问数据库那也是不太合适的。基于这种场景,那么我们就能够採用数据库验证方式来限制sys用户必须输入正确的username和password才干够訪问数据库。

    这种话。当SA没有DBA的syspassword,就无法訪问数据库了。


    在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用户也无需再验证password了


    假设设置成(NONE)。就表示採用数据库身份验证,还能够设置成(NONE,NTS)。事实上这样设也没有意义了。仅仅要括号里有NTS,就会採用操作系统验证,NONE就没实用了


    这里要指出一点,有些文章中说还能够设置成(ALL),但我设计測试下来。假设设置成(ALL),会提示ERROR:
    C:Documents and SettingsAdministrator>sqlplus / as sysdba


    SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:26:06 2014


    Copyright (c) 1982, 2005, Oracle.  All rights reserved.


    ERROR:
    ORA-12641: 验证服务无法初始化


    请输入username:


    如,下面这段描写叙述:
    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 methods
    NTS for Windows NT native authentication(An authentication method that enables
    a 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 SettingsAdministrator>sqlplus / as sysdba


    SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:50:49 2014


    Copyright (c) 1982, 2005, Oracle.  All rights reserved.


    ERROR:
    ORA-01031: 权限不足




    请输入username:  sys as sysdba
    输入口令: --此处输入正确的password“oracle”


    连接到:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options

    SQL>


    --断开连接。把(NONE)改为(NTS)直接连接
    SQL> disc
    从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options 断开
    SQL> conn abc/123 as sysdba
    ERROR:
    ORA-01031: 权限不足



    因为没有退出SQLPLUS,刚才改的(NTS)还未生效,可见sqlnet.ora文件是在进入SQLPLUS时才去读取的


    --仍然保持(NTS)。退出SQLPLUS后又一次登陆
    SQL> exit


    C:Documents and SettingsAdministrator>sqlplus / as sysdba


    SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 8月 28 21:54:52 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>


    如今又是操作系统验证了


    注意,假设改成(NONE)以后。当使用RMAN时,system用户就不能操作了,输入正确的password也不行,仅仅有sys用户并输入password才干够,測试例如以下:


    --设置为(NTS)的时候登陆RMAN
    C:Documents and SettingsAdministrator>rman target /


    恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:07 2014


    Copyright (c) 1982, 2005, Oracle.  All rights reserved.


    连接到目标数据库: ORCL10G (DBID=1041171248)


    RMAN> exit




    恢复管理器完毕。


    C:Documents and SettingsAdministrator>rman target system/oracle


    恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:02:33 2014


    Copyright (c) 1982, 2005, Oracle.  All rights reserved.


    连接到目标数据库: ORCL10G (DBID=1041171248)


    RMAN> exit




    恢复管理器完毕。


    --改动为(NONE)后。再用password登陆一次RMAN
    C:Documents and SettingsAdministrator>rman target system/oracle --注意,这里password是正确的


    恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:06 2014


    Copyright (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 SettingsAdministrator>rman target /


    恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:08:47 2014


    Copyright (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 SettingsAdministrator>rman target sys/oracle


    恢复管理器: Release 10.2.0.1.0 - Production on 星期四 8月 28 22:03:16 2014


    Copyright (c) 1982, 2005, Oracle.  All rights reserved.


    连接到目标数据库: ORCL10G (DBID=1041171248)


    RMAN>


    非常显然,在採用数据库身份验证以后,system用户被禁止使用RMAN了,仅仅有拥有数据库最高权限的sys用户,才干登陆RMAN。并且必须是输入password的方式登陆


    总结:


    在windows下,SQLNET.AUTHENTICATION_SERVICES必须设置为NTS才干使用OS认证,不设置(如,把该行语句加#凝视符号)或者设置为其它不论什么值都不能使用OS认证。
    主要是下面几种情况:
    1. sqlnet.ora文件为空,或用#凝视掉              --基于Oraclepassword文件验证
    2. SQLNET.AUTHENTICATION_SERVICES = (NTS)       --基于操作系统验证
    3. SQLNET.AUTHENTICATION_SERVICES = (NONE)      --基于Oraclepassword文件验证
    4. SQLNET.AUTHENTICATION_SERVICES = (NONE,NTS)  --基于操作系统验证(前后顺序颠倒也一样)


    注意:默认情况下,Unix/Linux下的sqlnet.ora文件是没有SQLNET.AUTHENTICATION_SERVICES參数的,似乎连sqlnet.ora这个文件也没有,这和windows有非常大的不同
    此时是操作系统验证和Oraclepassword验证并存,假设加上SQLNET.AUTHENTICATION_SERVICES这个參数后。无论是设置为(NONE)、(NTS)或(NONE,NTS),都是基于Oraclepassword验证。




  • 相关阅读:
    mybatis中大于等于小于等于的写法
    RandomAccess接口
    ArrayList源码解析
    使用Docker搭建MySQL主从复制(一主一从)
    狂神Docker视频学习笔记(基础篇)
    【JQ】jQuery实现将div中滚动条滚动到指定位置的方法
    JAVA线程池的基本使用
    史上最全的Java技术体系思维导图,没有之一!
    springboot整合kafka
    spring cloud alibaba 分布式事务解决方案之seata-1.3.0
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/7265446.html
Copyright © 2011-2022 走看看