How to store the passwords securely and use in scripts?


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
How to store the passwords securely and use in scripts?

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.
# 2  
Quote:
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.
Hello karumudi7,

It is NEVER EVER recommended to store passwords either in plain text or in encrypted format. Why don't you try to use some certificate kind of thing(not sure in your app case), perfect example if password-less SSH which requires public key copied at target server and while making ssh it makes sure that user is NOT being asked for password etc.

Again DO NOT save passwords in any form, it is NEVER recommended at all.

Note: after Neo' comment adding this, you could not avoid writing passwords always but still use them safely.

Thanks,
R. Singh

Moderator's Comments:
Mod Comment Neo: Please do not delete "mistakes and wrong" answers that others have replied do. Everyone makes mistaken. Accept it and "move on".

Last edited by RavinderSingh13; 04-17-2019 at 12:19 AM..
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Yes, I understand and I use SSH keys for password-less connections.
But it is more like when you are interacting with other services like database etc.
This User Gave Thanks to karumudi7 For This Post:
# 4  
Ravinder,

Many systems on the network require passwords to be stored in a flat file.

It's not always avoidable, so you can't say "NEVER NEVER DO THIS"... spoken much like someone who has not built a production application which uses clear text passwords.

Theory is not always the same in practice.

Normally, these kind of DB passwords are stored in plaintext in files which are hidden from users, so we must look at who has access to the system, the risk, the criticality of the application and other risk management factors.

Quote:
Originally Posted by karumudi7
Yes, I understand and I use SSH keys for password-less connections.
But it is more like when you are interacting with other services like database etc.
This is correct. Many CMS programs like WordPress store the DB passwords in clear text in a flat configuration file.
These 2 Users Gave Thanks to Neo For This Post:
# 5  
Quote:
Originally Posted by Neo
Ravinder,

Many systems on the network require passwords to be stored in a flat file.

It's not always avoidable, so you can't say "NEVER NEVER DO THIS"... spoken much like someone who has not built a production application which uses clear text passwords.

Theory is not always the same in practice.
Normally, these kind of DB passwords are stored in plaintext in files which are hidden from users, so we must look at who has access to the system, the risk, the criticality of the application and other risk management factors.
This is correct. Many CMS programs like WordPress store the DB passwords in clear text in a flat configuration file.
Thank you Neo for correcting me, I have deleted my answer now, considering it was not adding any value add to post.

Thanks,
R. Singh
# 6  
Ravinder,

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!
This User Gave Thanks to Neo For This Post:
# 7  
The approach to manage risk in IT should be based on a risk analysis.

For example, a person running their own blog who has not much to lose if their DB password is compromised has a much different risk profile than a bank doing financial transactions.

Security controls come with "costs" and so the controls used should be appropriate to the risk profile of the system.

All WordPress blocks, Wikipedia Wikis and indeed most all CMS apps freely available on the network store DB password as clear text in config files which with various standard unix / linux file system permissions and controls.
These 2 Users Gave Thanks to Neo For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Store passwords , accounts, IPs, hostnames
funksen
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...... UNIX for Advanced & Expert Users
6
UNIX for Advanced & Expert Users
Oracle Passwords in Unix scripts
clifford
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...... Shell Programming and Scripting
5
Shell Programming and Scripting
Checking passwords - scripts
bullz26
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:... Shell Programming and Scripting
5
Shell Programming and Scripting
How to pass passwords to bash scripts?
siegfried
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=10.1.1.33,user=Administrator,password=$1 /mnt/mark I don't like the fact that I have to put...... Shell Programming and Scripting
5
Shell Programming and Scripting

Featured Tech Videos