Masking Password from within a Bash Shell Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Masking Password from within a Bash Shell Script
# 1  
Old 12-06-2011
Masking Password from within a Bash Shell Script

Is there a way to mask the password inside of a script to minimize the impact of a comprimised server? So

Code:
ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "mysqldump --opt --all-databases -u root -pPassword| gzip" > $backup_dir/mysqldump.gz

a seperate password file maybe and using backticks? Just throwing stuff out there

http://http://www.askdavetaylor.com/...ll_script.html

Code:
ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "mysqldump --opt --all-databases -u root -p`cat /some/dir/passwd_file`| gzip" > $backup_dir/mysqldump.gz

??

Last edited by metallica1973; 12-06-2011 at 11:10 PM..
# 2  
Old 12-06-2011
you need to setup the "passwordless ssh" (google it) How to Setup Password-less SSH Using Public - Private Keys
# 3  
Old 12-07-2011
That won't mask it, no. It'll still show it because it'll have to figure out what the password is before it runs the command, how else could it do it?

If you could give mysql just -p instead of '-ppassword' it might read it from stdin, so you could redirect a local file into ssh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script for password changes help

I am super new to scripting and I am trying to create a bash script that is interactive that will change other user passwords as well as a few other thing (ie. change SMB pw, see pw expiration,lock/unlock user). I have started it by making it check to see if the username entered is in the... (2 Replies)
Discussion started by: thumbelina
2 Replies

2. Shell Programming and Scripting

Help with Shell Scrip in Masking particular columns in .csv file or .txt file using shell script

Hello Unix Shell Script Experts, I have a script that would mask the columns in .csv file or .txt file. First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder. Two parameters are passed ... (5 Replies)
Discussion started by: Mahesh G
5 Replies

3. Shell Programming and Scripting

Bash - Comparing 2 xml strings masking certain fields

Would like to compare 2 XML Strings which has certain known fields changed. For example, Date field will always have differences. When comparing both strings, skip/mask all the occurring Date Field's `DtField1` and `DtField2` Note: these are not formatted xml format. File1: ... (1 Reply)
Discussion started by: Sajjadmehdi
1 Replies

4. Shell Programming and Scripting

Make a password protected bash script resist/refuse “bash -x” when the password is given

I want to give my long scripts to customer. The customer must not be able to read the scripts even if he has the password. The following command locks and unlocks the script but the set +x is simply ignored. The code: read -p 'Script: ' S && C=$S.crypt H='eval "$((dd if=$0 bs=1 skip=//|gpg... (7 Replies)
Discussion started by: frad
7 Replies

5. Shell Programming and Scripting

bash script for password recovery

Hi all, I'm a complete newbie to bash scripting, although I have some experience in programming. The thing is that I have a .dmg file on my mac which I protected with a password, and now I've forgotten it. I remember the first few letters of the password and the characters that represent the... (4 Replies)
Discussion started by: sujay.jauhar
4 Replies

6. Programming

Masking Password with *'s

So I've been working on this for some time now and can't seem to find the solution that works for me. I'm working in C/Unix. Basically, I want to take a user input and output something different. For example, I want to take a password and output *'s. In another instance, I want to take inputed... (35 Replies)
Discussion started by: bigdrock44
35 Replies

7. Shell Programming and Scripting

Scripting help/advise on hiding/masking username/password

Hi, I currently have a UNIX script with a function that uses a username and password to connect to the database, retrieve some information and then exit. At the moment, am getting the username and password from a hidden plain text file and permission set to -r--------, i.e. read only to who... (1 Reply)
Discussion started by: newbie_01
1 Replies

8. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

9. UNIX for Dummies Questions & Answers

masking or encrypting in shell script

Hi folks, I am writing a script which asks the user to enter a user name and password to telnet and logon to some other machine. The script promts the user to enter the login name and password as below. echo "Enter the login name to be used to login on the machine" read login echo "Enter the... (4 Replies)
Discussion started by: dshrish
4 Replies

10. UNIX for Dummies Questions & Answers

Masking input in a shell script

How do I prevent user input from being displayed in running script (e.g. when entering a password)? Thanx, Aaron (2 Replies)
Discussion started by: Spetnik
2 Replies
Login or Register to Ask a Question