2017.05.07的实验探究,这里补上。
环境说明:1.操作系统版本
- [oracle@oracle ~]$ uname -a
- Linux oracle.example.com 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
- [oracle@oracle ~]$ lsb_release -a
- LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
- Distributor ID: RedHatEnterpriseServer
- Description: Red Hat Enterprise Linux Server release 6.5 (Santiago)
- Release: 6.5
- Codename: Santiago
- SYS@proc> select * from v$version where rownum=1;
-
- BANNER
- --------------------------------------------------------------------------------
- Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
实验过程:
1.禁用OS(操作系统)认证,避免OS带来的影响
- [oracle@oracle admin]$ ll
- total 20
- -rw-r--r--. 1 oracle oinstall 293 Oct 20 06:10 listener.ora
- drwxr-xr-x. 2 oracle oinstall 4096 Oct 19 10:29 samples
- -rw-r--r--. 1 oracle oinstall 381 Dec 17 2012 shrept.lst
- -rw-r--r--. 1 oracle oinstall 141 Dec 17 03:47 sqlnet.ora
- -rw-r--r--. 1 oracle oinstall 334 Dec 5 12:42 tnsnames.ora
-
- [oracle@oracle admin]$ more sqlnet.ora
- TNSPING.TRACE_LEVEL=SUPPORT
- TNSPING.TRACE_DIRECTORY=/u01/app/oracle/diag/tnslsnr/oracle/listener/trace
- SQLNET.AUTHENTICATION_SERVICES = NONE (加上该行,作用是禁用OS认证)
-
- [oracle@oracle admin]$ sqlplus / as sysdba
- SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 17 04:29:03 2016
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- ERROR:
- ORA-01017: invalid username/password; logon denied (说明OS认证已经禁用)
- Enter user-name:
-
- [oracle@oracle admin]$ sqlplus sys/oracle as sysdba (口令文件认证登录,若OS认证未禁用,则优先使用OS认证)
- SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 17 04:38:41 2016
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- Connected to an idle instance.
- SYS@proc>
- [oracle@oracle dbs]$ ll
- total 24
- -rw-rw----. 1 oracle oinstall 1544 Dec 17 04:21 hc_proc.dat
- -rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
- -rw-r--r--. 1 oracle oinstall 891 Dec 7 07:01 initproc.ora
- -rw-r-----. 1 oracle oinstall 24 Oct 19 10:41 lkPROC
- -rw-r-----. 1 oracle oinstall 1536 Dec 17 04:31 orapwdproc
- -rw-r-----. 1 oracle oinstall 3584 Dec 17 04:06 spfileproc.ora
- [oracle@oracle dbs]$ cp orapwdproc orapwdproc.bak
- [oracle@oracle dbs]$ rm orapwdproc
- [oracle@oracle dbs]$ ls
- hc_proc.dat init.ora initproc.ora lkPROC orapwdproc.bak spfileproc.ora
- [oracle@oracle dbs]$ sqlplus sys/oracle as sysdba
- SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 17 04:33:18 2016
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- ERROR:
- ORA-01017: invalid username/password; logon denied (口令文件认证登录失效)
- Enter user-name:
- [oracle@oracle dbs]$ orapwd file=orapwproc password=abc
- [oracle@oracle dbs]$ sqlplus sys/oracle as sysdba (使用原密码登录)
- SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 17 04:43:00 2016
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- ERROR:
- ORA-01017: invalid username/password; logon denied
- Enter user-name: ^C
- [oracle@oracle dbs]$ sqlplus sys/abc as sysdba (使用口令文件新指定的密码)
- SQL*Plus: Release 11.2.0.4.0 Production on Sat Dec 17 04:43:10 2016
- Copyright (c) 1982, 2013, Oracle. All rights reserved.
- Connected to an idle instance.
- SYS@proc> (登录成功)
实验结论以及分析:
1.本地使用"sqlplus / as sysdba"时,优先使用的是OS认证。
在OS情况下,作为"as sysdba"也就是sys用户登录的话,会无视用户名和密码(无论用户原先是否存在),比如使用"sqlplus test/test as sysdba"也是能够登录上去的。
因为安全性是基于操作系统的。因此本实验要先禁用OS认证,避免OS认证带来的影响。
2.当OS认证被禁用之后,则本地登录的话会使用口令文件,所以当sys用户密码忘记的时候,不用操作系统认证的情况下,可以通过重建口令文件修改sys用户密码。
数据库使用alter user sys identified by xxxx;所更改的密码也会保存到口令文件中。
3.一张相关的图片
4.Oracle提供了一个视图v$pwfile_users 来方便查看pwd file里面有哪些特权用户:
sql代码 select * from v$pwfile_users;
5.其他资料:
Oracle中的口令文件存放着系统的特权用户(sysdba, sysoper)用户的用户名及口令,允许用户通过口令文件验证,在数据库未启动之前登陆从而启动数据库。如果没有口令文件,在数据库未启动之前就只能通过操作系统认证。
可以知道即使没有口令文件,非特权用户(sysdba, sysoper)在知道密码的情况下也是可以登录成功的。
其他拓展内容:
1.操作系统认证(sqlnet.ora)
2.相关参数
- SYS@proc> show parameter remote_login_passwordfile
-
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- remote_login_passwordfile string EXCLUSIVE
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30174570/viewspace-2139943/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30174570/viewspace-2139943/