Oracle 11g通過wallet實現無密碼登入

feelpurple發表於2017-01-11
建立一個目錄來存放wallet
[oracle@localhost trace]$ mkdir -p /u01/app/oracle/wallets

在客戶端通過下面命令建立一個wallet
[oracle@localhost trace]$ mkstore -wrl /u01/app/oracle/wallets -create
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.

Enter password:               

Enter password again:  

輸入的密碼是wallet的管理密碼,在建立具體使用者的wallet時需要用到

在目錄下會生成下面檔案
[oracle@localhost wallets]$ ls /u01/app/oracle/wallets
cwallet.sso  ewallet.p12

建立資料庫連線證照
[oracle@localhost trace]$ mkstore -wrl /u01/app/oracle/wallets -createCredential DB_FIRE  scott
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.

Your secret/Password is missing in the command line
Enter your secret/Password:        # 輸入scott的密碼

Re-enter your secret/Password:        # 再次輸入scott的密碼

Enter wallet password:               # 輸入wallet的管理密碼
   
Create credential oracle.security.client.connect_string1

/u01/app/oracle/wallets是在之前建立的wallet存放路徑
DB_FIRE是TNS中的連線名
scott是資料庫中的使用者名稱

[oracle@localhost admin]$ cat tnsnames.ora
DB_FIRE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1536))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = OTA4GSRV)
    )
  )

在sqlnet.ora檔案中,編輯WALLET_LOCATION引數,將目錄路徑設定為上面建立的wallet存放路徑
SQLNET.WALLET_OVERRIDE引數為TRUE,會覆蓋系統本身存在的外部安全認證,啟用資料庫認證

[oracle@localhost admin]$ vi sqlnet.ora
WALLET_LOCATION =
  (SOURCE =
    (METHOD = FILE)
    (METHOD_DATA =
  (DIRECTORY = /u01/app/oracle/wallets)
  )
 )

SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_VERSION = 0

通過下面方式實現無密碼登入
[oracle@localhost admin]$ sqlplus /@DB_FIRE

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 11 11:59:47 2017

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>   

檢視外部密碼存放內容
[oracle@localhost admin]$ mkstore -wrl /u01/app/oracle/wallets -listCredential
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:               

List credential (index: connect_string username)
1: DB_FIRE scott

刪除外部密碼存放的證照
[oracle@localhost admin]$ mkstore -wrl /u01/app/oracle/wallets -deleteCredential DB_FIRE  scott
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:               

Delete credential
Delete 1
test invalid
Invalid command: scott

[oracle@localhost admin]$ mkstore -wrl /u01/app/oracle/wallets -listCredential
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:               

List credential (index: connect_string username)

刪除證照後,通過無密碼方式登入時,會提示錯誤
[oracle@localhost admin]$ sqlplus /@DB_FIRE

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 11 14:27:27 2017

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

ERROR:
ORA-01017: invalid username/password; logon denied

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2132246/,如需轉載,請註明出處,否則將追究法律責任。

相關文章