How to list users without MD5 encrypted password?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to list users without MD5 encrypted password?
# 1  
Old 12-03-2015
How to list users without MD5 encrypted password?

Hi,

As a security measure, we need to force all the users to use MD5 encryped passwords. For that we need to list users whose encrypted password is not MD5. I understand all MD5 encrypted passwords start with $1$ and a sample entry in /etc/shadow would be

Code:
user03:$1$ZiusVx0w$z2qflR9tefr4VKzi4/.va/:15266:0:99999:7:::

I tried grep -v ":$1$" /etc/shadow and grep -v ":\$1\$" /etc/shadow and grep -v :\$1\$ /etc/shadow to list the entries without MD5 encryption but no luck (none of them give expected output)

Please advise the correct way to get the user list without MD5 encrypted passwords. Thank you!


.
# 2  
Old 12-03-2015
What platform are you on? Most pam-compatible systems allow the sysadmin to specify the encryption algorithm.

So before we go further, do you have a lot of users with root access? If not, then why have you not already specified the encryption algorithm? After that, you should have expired all passwords, thus forcing them to use your specified algorithm. Problem solved, IMO.

And if you have users with root access you cannot stop them from doing pretty much anything they please.

As you can see, I do not think what you are trying to do, as stated, is going to help much. So we need to know more.

As to your question: fgrep or grep -F tells grep not to use regex.
Code:
grep -F ':$1$' /etc/shadow

awk works, too:
Code:
awk -F':' 'index($2, "$1$")==1'  /etc/shadow


Last edited by jim mcnamara; 12-03-2015 at 10:28 PM..
# 3  
Old 12-04-2015
Code:
grep -Ev "^[^:]+:[$]1[$]" /etc/shadow

# 4  
Old 12-04-2015
Thanks both.

That's what exactly I need at the moment - to list the users without MD5. This is on RHEL 6.7.

However the plan is to change default encryption algorithm to SHA512 and force users to change their password which I plan to do by below 2 commands:

Code:
authconfig --passalgo=sha512 --update

Code:
for u in $(awk -F: '{if ( $1 != "root" && $2 ~ /^!?[[:alnum:]\.\/\$]/ ) print $1}' /etc/shadow); do chage -d0 $u; done

Thanks again!
# 5  
Old 12-04-2015
I think, it is already approx. 10 years at least, as MD5 is considered insecure.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

Is TLS encrypted password safe?

Hello, on my android device my app autosaves my password and it encrypts by TLS im not politically exposed person, just regular entrepreneur. Should i worry if i loose my phone with TLS encrypted password? Or regular mortals or casual hackers are not able to crack it? (4 Replies)
Discussion started by: postcd
4 Replies

2. Shell Programming and Scripting

Encrypted password in script

How to keep encrypted password in a shell script.? I have the file which has the following: a.sh ----- username=abc password=abc I will be using this username and password in another script. But I don't want to reveal the password in the script. How to keep the password... (3 Replies)
Discussion started by: sanvel
3 Replies

3. UNIX for Dummies Questions & Answers

Using the encrypted password of the shadow file

i have an application that uses the encrypted password that's in the /etc/shadow file. i copied the line for the particular username i was interested it in from shadow file and i pasted it into the password file of the application. the application is nagios. this application allowed that... (5 Replies)
Discussion started by: SkySmart
5 Replies

4. Linux

Convert MD5 password to SHA-512?

Hi, Is it possible to convert MD5 passwords to SHA-512? I'm about to migrate an old slackware server to Debian, then I noticed that they don't use same encryption method. I'm aware that I can change the encryption method in Debian to MD5, but as far as I understand SHA-512 is more secure,... (2 Replies)
Discussion started by: urandom
2 Replies

5. UNIX for Advanced & Expert Users

/etc/shadow encrypted password

Hi I wonder whether is possible to generate enrypted passwd for some user and paste it into /etc/shadow file ? What kind of encryption is used in /etc/shadow file ? ths for help. (1 Reply)
Discussion started by: presul
1 Replies

6. Shell Programming and Scripting

To decrypt encrypted password

Hi folks, What will be the easy way to decrypt encrypted passwords on MySQL table. Googling brought me many suggestions on crypt/decrypt running scripts. Please advise. TIA Remark: I think the encrypt function of MySQL uses the Unix crypt command to encrypt B.R. satimis (1 Reply)
Discussion started by: satimis
1 Replies

7. UNIX for Dummies Questions & Answers

User Name and Password List/adding and removing users.

Hello everyone and let me start off by thanking anyone who can help with this. I work for a company that uses Unix as one of their servers. I'm not at all familar with Unix beyond logging after I restart the server:rolleyes: I'm looking for some command that will bring me up a list of current... (3 Replies)
Discussion started by: disgracedsaint
3 Replies

8. UNIX Desktop Questions & Answers

list the password settings for all the users

Hi!! How can I list the password settings for all the users?? Best regards (3 Replies)
Discussion started by: irasela
3 Replies

9. UNIX for Dummies Questions & Answers

Change password by pushing encrypted password to systems

I'm tasked to change a user's password on multiple Linux systems (RH v3). I though copying the encrypted password from one Linux /etc/shadow file to another would work but I was wrong. The long term solution is to establish an openLDAP Directory service, but for now I'm stuck with a manual... (1 Reply)
Discussion started by: benq70
1 Replies

10. UNIX for Advanced & Expert Users

netrc file encrypted password

Hi, I do not want the plaintext password to appear in the netrc file. So I want to encrypt the password. Is there a way to encrypt the password and still make ftp to use the netrc ? Thanks in advance. -Gow:confused: (2 Replies)
Discussion started by: ggowrish
2 Replies
Login or Register to Ask a Question