Sponsored Content
Top Forums Shell Programming and Scripting Best Approach To Encrypt The Passwords Post 302916748 by Corona688 on Thursday 11th of September 2014 06:32:13 PM
Old 09-11-2014
Quote:
Originally Posted by Ariean
I have a .passwd file where i am encrypting the passwords and when the application account runs the shell script i am exporting the variables as shown below.

.passwd file
Code:
DBBATCHUSER|Redacted
DBBATCHPASS|Redacted

.dwrc file to export the passwords
Code:
export DBBATCHUSER=`cat "${BIN_DIR}"/.passwd | grep "DBBATCHUSER" | awk -F "|" '{print $2}' | openssl enc -base64 -d`
export DBBATCHPASS=`cat "${BIN_DIR}"/.passwd | grep "DBBATCHPASS" | awk -F "|" '{print $2}' | openssl enc -base64 -d`

shell scripts executes oracle packages etc with passwords exported sourcing .dwrc file
Code:
#!/bin/bash
. /usr/local/dw/.dwrc

All your encoding / decoding code is pointless because:

Moderator's Comments:
Mod Comment Encryption does not work that way.


Forgive me for being a bit emphatic, but we get these threads very often.

Quote:
1) Does open ssl base means i am doing encoding only not encrypting
I can decrypt them from here whether it was base64, aes256, or some weird cipher of your own design, because I saw your code. You are not protecting the passwords this way since the script remains vulnerable. In short:

Moderator's Comments:
Mod Comment Encryption does not work that way.


Quote:
2) would you suggest better encrypting utility to encrypt the passwords?
There is no "better" here, because protecting the file and not protecting the script is like a screen door in a submarine. Pointless. In short:

Moderator's Comments:
Mod Comment Encryption does not work that way.


Quote:
3) I have more than 10 oracle packages or 10 different steps where i have to log to the database to execute the packages as part of shell script, with out exporting them as variables do i have to read the .passwd file 10 times to execute my packages?
Yes. Compared to the work it takes to run 10 Oracle packages, that's miniscule...

Quote:
even then SUDOing to the functional account would still allow to read the passwords in .passwd file?
You can configure sudo to not do that.

Code:
%someusergroup ALL=NOPASSWD: (passworduser) /path/to/mydbscript.sh

This would allow users in 'somegroup' to run /path/to/mydbscript.sh as 'passworduser'. If they tried to do anything else with 'passworduser' it wouldn't let them.

Last edited by Corona688; 09-11-2014 at 07:43 PM..
These 2 Users Gave Thanks to Corona688 For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Approach to writting a script

Hello all, I've just joined. I did a google search and your site came up, I had a look and thought I'd like to become a member. I'm from Ireland. I've written a few scripts before, but this new task has me foxed. I would like to figure out the best approach to achieving the following ... (15 Replies)
Discussion started by: Bloke
15 Replies

2. Homework & Coursework Questions

How to approach Julian date?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This function is given the day, month and year and returns the Julian date. The Julian date is the... (1 Reply)
Discussion started by: mgyeah
1 Replies

3. UNIX for Advanced & Expert Users

When did UNIX start using encrypted passwords, and not displaying passwords when you type them in?

I've been using various versions of UNIX and Linux since 1993, and I've never run across one that showed your password as you type it in when you log in, or one that stored passwords in plain text rather than encrypted. I'm writing a script for work for a security audit, and two of the... (5 Replies)
Discussion started by: Anne Neville
5 Replies

4. Shell Programming and Scripting

Approach on Header record

All, I currently have a requirement to fetch a Date value from a table. And then insert a Header record into a file along with that date value. ex: echo "HDR"" "`date +%Y%j` `date +%Y%m%d` In the above example I used julian date and standard date using Current Date. But the requirement... (0 Replies)
Discussion started by: cmaroju
0 Replies

5. Programming

Oracle Procedure approach

HI All , I am new to oracle procedures. Please help me for the approach to satify the requirement. I need to create procedures. with parameters passed ( say report,type,identities,country ) It should also call sql query within the procedures and passed parameters should be used in where clause... (2 Replies)
Discussion started by: Perlbaby
2 Replies

6. Red Hat

What would be the best approach?

I have a table in one of my DB. The DB is about 300 gig - of that 249 gig is in this table. The data is somewhat important but even if we delete half of it won't affect anybody. I would like to reclaim some space back so my question is what would be the best approach to accomplish this task.... (6 Replies)
Discussion started by: newborndba
6 Replies

7. Shell Programming and Scripting

Help with approach and developing script

Hi- I need to develop a script for following scenario in AIX and K shell environment.I am from windows server background for most my career ,so please bear with me and advise suitable approach and technical assistance.Having said that I am aware of unix shell commands but never pput together at... (1 Reply)
Discussion started by: nirasm
1 Replies

8. UNIX for Beginners Questions & Answers

What is the right approach to take?

Hello every one, I will love to know what is the best approach to take in obtaining books online. I find it disturbing just googling a book online and downloading it without actually paying for it. I strongly believe that this is wrong and that i may not be able to unlock the key contents and... (2 Replies)
Discussion started by: despiragado
2 Replies
All times are GMT -4. The time now is 07:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy