LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 06-24-2008, 01:29 PM   #1
DRiggs
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Rep: Reputation: 0
Updating a Shadow file password through a script


I have to connect into multiple Linux and UNIX boxes. My account password expires every 45 days. I would like to create a script utility to update the shadow file with the proper HASH for my new passwords monthly, but I cannot figure out how to get the proper HASH. Does anyone know how to do this?

I have seen many websites say to use "openssl passwd -1", but when I do this with my current password the result does not match what the shadow has...?

Last edited by DRiggs; 06-24-2008 at 02:35 PM. Reason: More information.
 
Old 06-24-2008, 04:15 PM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by DRiggs View Post
I have seen many websites say to use "openssl passwd -1", but when I do this with my current password the result does not match what the shadow has...?
It's not supposed to match. A salt is used every time you generate, so it's normal and expected to get different hashes for the same password every time. It's all good (they will work just fine). That said, if you have a need for the strings to be exactly the same for some reason, all you have to do is specify the salt when you execute the command. So, for example:

Instead of this:
Code:
openssl passwd -1
You would use something like this:
Code:
openssl passwd -1 -salt MySalt
Remember that the salt is always stored alongside the actual hash (it's the characters between the string's second and third dollar signs). In this example output string I've put the salt in red:
Code:
$1$d9FPOhLP$W8tk2xdaXuHqMSCWDVNml.
So if I wanted to generate this hash exactly as posted (assuming I know the password, of course), I would do a:
Code:
openssl passwd -1 -salt d9FPOhLP
Hope this helps, and BTW: Welcome to LQ!!!

Last edited by win32sux; 07-01-2008 at 02:19 AM. Reason: Added link.
 
  


Reply

Tags
password, shadow


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shadow file has !! for password field Z038 Linux - General 4 09-10-2007 07:40 AM
Question about information contained in Shadow Password file cruzzz01 Linux - Security 1 06-13-2006 04:34 PM
LXer: Recovering deleted /etc/shadow password file LXer Syndicated Linux News 0 12-21-2005 03:46 PM
How to encrypt a password to the /etc/shadow file? Milosevic Linux - Newbie 2 12-13-2005 02:14 PM
Apache and shadow password file fortezza Linux - Security 2 07-31-2005 06:49 PM


All times are GMT -5. The time now is 06:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration