关于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
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 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: 验证服务无法初始化
请输入用户名:
如,以下这段描述:
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 Settings\Administrator>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: 权限不足
请输入用户名: sys as sysdba
输入口令: --此处输入正确的密码“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 Settings\Administrator>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用户就不能操作了,输入正确的密码也不行,只有sys用户并输入密码才可以,测试如下:
--设置为(NTS)的时候登陆RMAN
C:\Documents and Settings\Administrator>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 Settings\Administrator>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)后,再用密码登陆一次RMAN
C:\Documents and Settings\Administrator>rman target system/oracle --注意,这里密码是正确的
恢复管理器: 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 Settings\Administrator>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 Settings\Administrator>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,而且必须是输入密码的方式登陆
总结:
在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密码验证。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

InnoDB的全文搜索功能非常强大,能够显着提高数据库查询效率和处理大量文本数据的能力。 1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。 2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。 3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

本文讨论了使用Drop Table语句在MySQL中放下表,并强调了预防措施和风险。它强调,没有备份,该动作是不可逆转的,详细介绍了恢复方法和潜在的生产环境危害。

本文讨论了在PostgreSQL,MySQL和MongoDB等各个数据库中的JSON列上创建索引,以增强查询性能。它解释了索引特定的JSON路径的语法和好处,并列出了支持的数据库系统。
