Visit The New, Modern Unix Linux Community

How to store the passwords securely and use in scripts?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to store the passwords securely and use in scripts?
# 8  
Originally Posted by Neo
Please do not delete "wrong answers or mistakes" which people have replied to.
Everyone makes mistakes.
However, deleting posts which two people have replied is not really correct and is a "bigger mistake", in my view.
Just accept that you learned something and moved on; but I do recommend caution when you have strong opinions based on theory that do not match practical 'the way things are'... we all make mistakes. That's what makes life fun and interesting,
Plus, others can learn for your mistake, so please see it as a way to help others learn, thanks!
I Apologies for that Neo, will keep that in mind, cheers.

R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 9  
Hey Ravinder,

Don't worry about it at all.

Most people make the same mistake, because your original reply was based on the "correct theory" which is not to store passwords in clear text.

Unfortunately, in practice, as mentioned, every one of the millions of WP and CMS sites on the web all have clear text DB passwords stored in config files.

If you don't have experience with deploying these CMS, you would not know that.

In defense of freely available CMS software, they must store DB passwords somewhere, so generally speaking it is a matter of standard unix / linux filesystem and file security.
This User Gave Thanks to Neo For This Post:
# 10  
Originally Posted by karumudi7
I want to store the passwords in a global file, so that all the users will not use them to login but a process should use it. One way is to keep the passwords in a .ini file and execute the file in the start of the script and use that variable.

But with this, one can echo the variable in the script and see the value.

How are you guys storing, let's say production database password, and use that in the script while writing the database connect statements.
You should do a risk analysis and determine the threats, risk and vulnerabilities and decide the best controls to use based on your risk profile.

If I read your post correctly, you are working on a linux box (which one?) or unix box (which one?) in a commercial application with multiple users with access on that server.

So, you need to look at the permissions, and so I assume the DB is not running as root (that is very unusual), so it is running as a user with certain privs.

You need to example DB privileges relative to the users on the system and come up with a strategy to mitigate risk.

Normally, users cannot read others users files if the permissions are set so others cannot read or access.

So, if your DB process can read the file with the clear text password, but others users cannot, then that is obviously one first step.

If you describe your system environment in more details and your view of the risks (in the case of compromise), then I can assist further.

There is a difference based on the risk, as I have mentioned, and you need a variety of controls (physical, logical [meaning technical] and administrative [meaning rules in this context]) when viewing IT security controls.
# 11  
wordpress, wikipedia, et al don't encrypt their database passwords since there's not much point. They need the password every time. If it was encrypted, they'd just have to decrypt it, and if the program can do that without human input, so can an attacker.
This User Gave Thanks to Corona688 For This Post:
# 12  
I suppose it might just help to know what you are trying to connect to and using what tools. Smilie

As an example, if you are connecting to a local Oracle database instance then you can set up a user account with the phrase IDENTIFIED EXTERNALLY so that the DB trusts the OS user. Other options may be available.

Can you tell us what you actually need to create/obscure? It's all a bit crystal-ball-time at the moment.

Kind regards,
# 13  
Just to add to this, and to emphasize what others have said:

When we store a user password in the DB, for example a web site DB, that password is the cryptographic hash of the password + a bit of salt. When a user logs in they normally type a plain text password and that password is sent in plaintext across the net, hopefully in a secure SSL channel. At the server side, the plain text password is retrieved by the server side logic and then the cryptographic hash + salt is compared to the same in the DB.

In some cases, the hash (more often than not an "md5()" hash) is stored locally on the client side the hash is sent as a cookie (or a $_POST or $_GET var), for example, so the plaintext password is not required (this is but one scenario).

However, on the server, we assume there is some standard file system security in place.

So, when an application needs to access the DB, normally the password is stored securely in a plain text configuration file. Likewise, we can store the hash instead of the password, but since the hash of the password and the password can both be used to gain access, most "day to day CMS" systems store the plaintext password in a secure file.

Some people hide this file is some obscure location on the server, like in a "hidden" dot file. This kind of security-by-obscurity is not very good, but some think it is better than nothing.

However, this is just a description of basic authentication.

Systems which have a higher risk use more complex (and expensive) methods for authentication.

As Robin mentioned, we need the details of the application and basic system architecture to properly advise; and as I have mentioned, we should know the risk profile of the system, to really help you.
This User Gave Thanks to Neo For This Post:
# 14  
Sorry for the late message....

Thanks for all the valuable inputs.

Here is the scenario:
I have a group of developers that write scripts on AIX 7.
I don't want everyone to hard code the database (IBM DB2) passwords in their shell script.
If I put the global configuration file and controlled with file system permissions, one can use

statement to split that into a log.

I think the other way to achieve is, if I provide a database connect method in global file, then one can call the method when the script needs to connect to database. Still there will be security gaps, but may be a workaround.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #585
Difficulty: Easy
Most object oriented programming languages such as C++ and Java are class-based languages.
True or False?

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Store passwords , accounts, IPs, hostnames

Hi, this question is not specially unix related, but I expect advanced and expert unix users to have a solution for this, and I've found no other subforum that fits ;) what do you use to store accounts, customer ids, ip addresses, users and specially passwords, to access them from... (6 Replies)
Discussion started by: funksen
6 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
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

SSH - Passing Unix login passwords through shell scripts

Hi All , I need to call a script on server A, the script locating in server B. The in calls another script runscript_A on server A itself. it seend, i need to be connect from Server A to Server B using ssh. I have tryed like this in... (3 Replies)
Discussion started by: koti_rama
3 Replies

5. Shell Programming and Scripting

Oracle Passwords in Unix scripts

Hi Most of the shell scripts I am dealing with have to connect to oracle database . The username password is stored in a environment file which sets the variables for username and password . Set user id do not work on AIX so users who will execute these scripts need to have read or execute... (5 Replies)
Discussion started by: clifford
5 Replies

6. Solaris

installing solaris securely

Ok, I am trying to install solaris, but I would like as a lean installation as possible (while still having a shread of functionality). If I chose the minimal install I have little if no utilities to do work on the box. My question is what installation method do most admins take? ... (7 Replies)
Discussion started by: liven
7 Replies

7. Shell Programming and Scripting

Checking passwords - scripts

Hi Unix experts.... I am in the process checking user and root password of more than 1000 servers manulay. I am very pissed of checking these many servers manualy. Could some one of you help me how can i check the passwords just by runing some scripts..! Need Help Guys..! :confused: (5 Replies)
Discussion started by: bullz26
5 Replies

8. Shell Programming and Scripting

How to pass passwords to bash scripts?

I'm finding the following command very tedious to type in all the time, so I created a one line bash script called mount.bash with the following contents: mount -t cifs //mark/C\$ -o unc=//mark\\C$,ip=,user=Administrator,password=$1 /mnt/mark I don't like the fact that I have to put... (5 Replies)
Discussion started by: siegfried
5 Replies

Featured Tech Videos