Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

oracle automated login script

Posted on 2013-02-04
11
Medium Priority
?
488 Views
Last Modified: 2013-02-04
I have always used a unix script to pass my oracle ID/PASSWORD.
Now we cannot have and script on the system that contains a password.
We also are not supposed to use / as sysdba

On oracle 10g - aix and Linux.

Is there a way to set up and environment variable that you can do a

sqlplus $LOGIN_ID

run a script - say -
select * from v$instance;
alter user userid identified by newpassword;

Thanks
0
Comment
Question by:bkreynolds48
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38851478
Can you use OS Authentication?

This allows you to use sqplplus / (without the 'as sysdba').

If not, I don't think you can connect to the database without the credentials coming from somewhere.

>>run a script - say -

I don't understand what you are thinking about here.  Can you explain what your proposed script will do?
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 38851524
just want to connect to a database

sqlplus $oracle_login
select * from v$instance;
alter user USERID identified by NEWPASSWORD;
exit;

or run some other command - I just need a way to enter the ID/PASSWD for oracle without putting it in a file

file name
oracle.login

in the oracle.login file I had

userid/password


so I would just do

sqlplus <oracle.login
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38851537
You didn't answer this:  Can you use OS Authentication?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:bkreynolds48
ID: 38851547
here is an example of what I have done in the past

#
#!/bin/ksh
#
ORACLE_HOME=/export/home/oracle/product/10_2;export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib/;export LD_LIBRARY_PATH
ORACLE_SID=PROD;export ORACLE_SID
PATH=$PATH:$ORACLE_HOME/bin:/usr/local:/usr/ucb:/usr/ccs/bin:/export/home/oracle/oradba:/usr/local/bin;export PATH

/export/home/oracle/product/10_2/bin/sqlplus -s @/export/home/oracle/myid/sql/oracle.login << EOF  
@/export/home/oracle/myid/sql/rbsoffline.sql
exit
EOF
#


Now I cannot store my oracle ID/PASSED in a file like oracle.login
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38851570
>>Now I cannot store my oracle ID/PASSED in a file like oracle.login

I understand this.  You are not answering my questions.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 38851586
Check out this option:
Secure External Password Store

http://www.oracle-base.com/articles/10g/secure-external-password-store-10gr2.php
0
 
LVL 35

Expert Comment

by:johnsone
ID: 38851613
What you are thinking of doing is possible.  You could so something like:

oracle_login="user/pass"
export oracle_login

Then run your script.

However, I'm pretty sure that your security people would have just as much of an issue with doing it this way because a privileged username and password would still be visible to ps because it would be passed via command line.

To appease the security people, you should look at something like what slightwv is suggesting.  Passwords secured in a secured and encrypted file somehow.  Then having a script that accesses the passwords.  Be careful not to pass that to a command line though as you will still have the same visible via ps command problem.
0
 
LVL 1

Author Comment

by:bkreynolds48
ID: 38851641
I am reading the do that slightwv recommend

If I do this

oracle_login="user/pass"
export oracle_login


do you just do

sqlplus $oracle_login
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 38851665
>>sqlplus $oracle_login

As johnsone stated:  DO NOT do this.  If you provide the username and password as a command line argument this way, anyone on the Unix machine with a command prompt can see your password with a simple 'ps' command.

>>oracle_login="user/pass"

You 'can' do this but what does it do for you?  You still have to have the password stored somewhere or you need to type it in.

If you are willing to type it in, then there is no need to do this in the first place.
0
 
LVL 1

Author Closing Comment

by:bkreynolds48
ID: 38851670
Thanks
0
 
LVL 35

Expert Comment

by:johnsone
ID: 38851699
If you wanted to use the environment variable and have it not show up on the command line, you would have to do something like this:

sqlplus /nolog << EOF
connect $oracle_login
....
exit
EOF

That should keep it off the command line.  But, as has been pointed out, you still need to set that variable before you can run that script.  You would have to do it through commands and couldn't keep it in the profile scripts as that would be keeping it in a human readable file.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question