LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 04-26-2011, 11:19 AM   #1
themanwhowas
Member
 
Registered: Nov 2005
Distribution: CentOS 5, Fedora 23
Posts: 218

Rep: Reputation: 29
shadow password hashes


Hey guys

Two questions, 1 - Is the following correct:

The /etc/shadow file contains an id of $1$, $2$, $5$ or $6$ to show the encryption method used. A salt follows this, followed by the password hash. When a user is created and a password is set, a hash is RANDOMLY generated and used as the salt to the password hash. Everytime that user logs in, login checks /etc/shadow for the $id$ and salt and runs the password given by the user through the hash mechanism ($id$) using the salt in /etc/shadow.

So basically does login look at /etc/shadow for the $id$ and salt to create a hash with which to compare to the /etc/shadow hash?


question 2 - If my $id$ was $5$, which is sha256, how would i go about changing this? Like is there a shadow.conf or crypt.conf or something? Can i change it per user?


Thank you
 
Old 04-26-2011, 11:27 AM   #2
nomb
Member
 
Registered: Jan 2006
Distribution: Debian Testing
Posts: 675

Rep: Reputation: 58
Quote:
Originally Posted by themanwhowas View Post
Hey guys

Two questions, 1 - Is the following correct:

The /etc/shadow file contains an id of $1$, $2$, $5$ or $6$ to show the encryption method used. A salt follows this, followed by the password hash. When a user is created and a password is set, a hash is RANDOMLY generated and used as the salt to the password hash. Everytime that user logs in, login checks /etc/shadow for the $id$ and salt and runs the password given by the user through the hash mechanism ($id$) using the salt in /etc/shadow.

So basically does login look at /etc/shadow for the $id$ and salt to create a hash with which to compare to the /etc/shadow hash?


question 2 - If my $id$ was $5$, which is sha256, how would i go about changing this? Like is there a shadow.conf or crypt.conf or something? Can i change it per user?


Thank you
Just after a quick once over that looks correct.

Some distros have a command which will change all the appropriate files for you, but in a nutshell you will need to change PAM and the system itself.

Take a look at (again may be different in other distros):
/etc/pam.d/password
/etc/default/password
/etc/login.defs

After you change the type of hash, you will have to regenerate the password hashes for your users.
 
Old 04-26-2011, 12:32 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by nomb
Some distros have a command which will change all the appropriate files for you, but in a nutshell you will need to change PAM and the system itself.
That's right. It is a good idea to include your distro / version in your initial post.

Quote:
Originally Posted by nomb
After you change the type of hash, you will have to regenerate the password hashes for your users.
Just to add some clarity: the original (pre-change) hash will still be supported in the sense that users with existing passwords should still be able to authenticate. But any passwd(1) changes from that point (post-change) going forward will use the new hash. You could conceivably have a shadow(5) file that contains users with both hash types.
 
  


Reply

Tags
crypt, hash, login, password, shadow



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
password expiration /etc/shadow itik Linux - Newbie 3 07-25-2008 12:17 PM
Shadow Password linuxjamil Linux - Server 1 08-04-2007 05:13 AM
shadow password - password field ayhopkins Linux - Security 8 11-17-2005 05:25 AM
useradd without shadow password twallstr Linux - Software 1 09-08-2005 02:14 PM
shadow password wincrk Linux - Security 3 03-16-2003 09:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:42 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration