blanking out passwords within a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting blanking out passwords within a file
# 1  
Old 02-28-2005
blanking out passwords within a file

I have a file in which I need to find every occurance of PASSWORD="somepassword" and replace the actual password with "xxx". Within the file that I am working, I can have combinations of PASSWORD or it can also show as RMT_PASSWORD. The 'edited' file (with passwords x'ed out) will then be emailed as file attachments. Is sed the right tool to use here? Can someone possibly give me an example?


Thanks in advance!
# 2  
Old 02-28-2005
sed 's/PASSWORD=".*"/PASSWORD="xxx"/'
# 3  
Old 02-28-2005
You can use sed to make this as,

# echo "PASSWORD="somepassword"" | sed 's/PASSWORD=.*/PASSWORD="xxx"/'
PASSWORD="xxx"

To simply text format and save the same contents then use PERL as,
# echo "PASSWORD="somepassword"" | perl -pi -e 's/PASSWORD=.*/PASSWORD="xxx"/'
PASSWORD="xxx"

HTH.
# 4  
Old 03-09-2005
hey guys thanks for the help!

For PASSWORD="123456" and RMT_PASSWORD="abc123" it works great. I can also get variations where I space on either side of the "=" sign. Example:

PASSWORD= "abc"
PASSWORD ="abc"
PASSWORD = "abc"

Is there an easier way to accomodate these than my idea which is to have 3 additional sed statements to account for these? (I'm sure there is).

Thanks in advance!!
# 5  
Old 03-09-2005
sed 's/PASSWORD[ ]*=[ ]*".*"/PASSWORD="xxx"/'

will replace the password including zero or more spaces around the "="
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. HP-UX

Passwords and shadows

version 11.22 1 - In this version there is the shadow file by default?. If so why when I search the file I get "No / etc / shadow file found"? 2 - What does the "*" in etc / password? at the beginning of each password? (1 Reply)
Discussion started by: shinju15
1 Replies

2. 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

3. Solaris

How to recycle old passwords by modifying /etc/passwd file ?

hi, has anyone here tried to recycle old passwords by copying something out of the passwd file and paste them back into the same passwd file ? can it work this way ? some of our applications passwords are expiring but they cannot be change due to application concerns, so therefore we must... (7 Replies)
Discussion started by: Exposure
7 Replies

4. Shell Programming and Scripting

passwords

Dear all, I need to automate/script a user password change process. I'm helpless cannot use expect since it's not installed and cannot install it either. Do i have an alternative. I can store the password in a file and that would be the password that would be set to all the users. If not i don't... (1 Reply)
Discussion started by: earlysame55
1 Replies

5. Windows & DOS: Issues & Discussions

A software or a batch file to genarate random passwords

Hi, Is there a batch file or any software to genarate random passwords and the passwords expire automatically after a stipulated time period. Please suggest. (1 Reply)
Discussion started by: dwiravi
1 Replies

6. UNIX for Dummies Questions & Answers

Batch file to change all passwords

Hi all I am using tru64 Unix and I want to use batch file which makes me to change all user passwords at the same time ,instead of changing everyone separately. Please could anyone help me to do that. bye. (2 Replies)
Discussion started by: ahmedbashir
2 Replies

7. Solaris

Passwords in /etc/shadow file

I want to import my passwd/shadow files from Solaris 6 to Solaris 10. I found that the encryption method for passwords has changed. Is there a command or script to convert the Solaris 6 passwords to Solaris 10? I have searched the net and just can't seem to find the answer. For Example: The... (6 Replies)
Discussion started by: westsiderick
6 Replies

8. UNIX for Dummies Questions & Answers

Passwords

I am running unix 11.xxx....How do you change a user password. The previous vs was passwd at the command prompt. This no longer works. Thanks for the help (3 Replies)
Discussion started by: turner.rd
3 Replies

9. UNIX for Dummies Questions & Answers

Transfer passwords

Problem: I transferred user accounts (using "ap") from our production SCO UnixWare (7.1.1) server to a new server that I will be implementing next week. After transferring all accounts and passwords to the "new" server, I had to force a password change for all users on the old one due to an... (1 Reply)
Discussion started by: dlkox
1 Replies
Login or Register to Ask a Question