How to hide/encrypt password in script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to hide/encrypt password in script?
# 1  
Old 09-06-2010
How to hide/encrypt password in script?

Hi

I have following problem Im writing a script (in bash ) , where need to be written login & passwd for databas client .
Its need to in following form login passwd@dbhostname .
The problem is so anybody can read it so the passwd & login are visible and thats not very safety .
Can anybody advice me how to hide the details ?
Shall I save it to another file (where the access rights will be restricted ? ) or is there another choice ?
thanks

Last edited by vbe; 09-06-2010 at 05:26 AM.. Reason: typos...
# 2  
Old 09-06-2010
Quote:
Shall I save it to another file (where the access rights will be restricted ? )
Thats how I do it... And in the script I read the file to load the content to initialise a variable... but of course Im sure there are other ways...
# 3  
Old 09-06-2010
Can you show us the script?
# 4  
Old 09-08-2010
who's ?
# 5  
Old 09-08-2010
You can use md5hash
echo -n AytosPouRwtaeiEinaiMalakas | md5sum --text > /path/to/save/the/passwd
Then You read the input of the user
Give paswd:****************
Code:
if [ `echo -n $UserInput | md5sum --text` = `cat /path/to/saved/passwd` ]; then echo "Login correct"; 
else
echo "try again"; fi

This User Gave Thanks to hakermania For This Post:
# 6  
Old 09-15-2010
to hakermania :

thanks good idea but i need to have it in scripts which will be performed via cron, so I cant use it in my case .

I need to have written: login passwd@host where login & passwd need to be hidden.
# 7  
Old 09-18-2010
You can download the sources of other programs that use the way you want to perform (like ftp in ubuntu (i dont know if it does exist in other OS) i think) and see how they do it.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to hide password in shell script?

I am writing a shell script for sql loader (just copy part of the code) : For security reason, I have to put the below loginName and password into another separate file instead of in the same file of this script. Anyone can give me a hand. Thanks. Shell Script :... (12 Replies)
Discussion started by: Jaewong
12 Replies

2. Shell Programming and Scripting

Encrypt and decrypt the password in a Shell Script

Hello, I have the following UNIX shell script which connects to the teradata database and executes the SQL Queries. For this, I am passing database name, username and password. I don't want to reveal my password to anyone. So, is there any way that I can encrypt my password and read the... (2 Replies)
Discussion started by: ronitreddy
2 Replies

3. Shell Programming and Scripting

Encrypt and decrypt a password in shell script

Hi All, very good morning all. I am trying to connect to informatica repository by using shell script. I have written pmrep connect command in the script file. But i need to provide repository, domain ,username and password to connect. Username and password are hard coded in the script... (8 Replies)
Discussion started by: SekhaReddy
8 Replies

4. Shell Programming and Scripting

Encrypt DB password in Script

Hi, I have a SQL which i want to run through a shell script. query_result=`/home/oracle/product/11.2.0/bin/sqlplus -S uname/pwd@DBNAME <<! set heading off feedback off trimspool on set pagesize 0 set linesize 9999 spool $PARAM_PATH/param_name.txt; Select sysdate from dual; spool off;... (6 Replies)
Discussion started by: chetan.c
6 Replies

5. Shell Programming and Scripting

how to encrypt a password in shell script

Hi, I have run the below script which is connected to db2 v9.5. There is no issue. The only problem is how to encrypt the dbpwd? #!/bin/ksh #---- Set Environment dbalias="dev1db" dbuser="user1" dbpwd="password" #---- Connect to the Database cd /opt/ibm/db2/V9.5/bin db2 "connect to... (1 Reply)
Discussion started by: lookinginfo
1 Replies

6. Shell Programming and Scripting

Best way to hide password in bash script?

Dear folks, The title of my thread says mostly all of what I want to do. Basically I want to auto-ssh to a remote host, and run a program on it (VLC is just an example). I wrote a script which calls xterm and then runs expect on it. The code is as follow #!/bin/bash export PASS="xxxxxxx"... (22 Replies)
Discussion started by: dukevn
22 Replies

7. UNIX for Advanced & Expert Users

Encrypt the password ,source it in a expect script...!!

Hello folks I have a conf file ,say 'pass.conf' ,which is storing ascii password : PASS1111. I need to encrypt this password once and store it in a file. I ,then need to write a script which would read this encrypted password and decrypts it.The o/p o this script shud be this decrypted... (8 Replies)
Discussion started by: ak835
8 Replies

8. Shell Programming and Scripting

Expect Script....encrypt password and use

Could someone please help me...I have an expect script. There's a need for a log in during the script and a password is required...right now the password is just a variable in the expect script...what would be the best way to put that in an encrypted flat file and have the expect script pull the... (2 Replies)
Discussion started by: cubs0729
2 Replies

9. Shell Programming and Scripting

How Do I Hide the Password in a Script

Hi, I am writing a UNIX .ksh script and need to send the login password of the login id that is executing the script to a command that I am executing in the script. I don't want that password to be seen by anyone except whoever is executing the script. Does anyone know how I can accomplish... (6 Replies)
Discussion started by: samd
6 Replies
Login or Register to Ask a Question