LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux passwords in /etc/shadow (https://www.linuxquestions.org/questions/linux-newbie-8/linux-passwords-in-etc-shadow-278335/)

LouisR 01-16-2005 02:22 AM

Linux passwords in /etc/shadow
 
Hello All,

Can someone please give me any insight on how the passwords in /etc/shadow are encrypted? I am attempting to develop a script that will update /etc/shadow with a new user password, but I don't know how the passwords are encrypted/hashed.

Also, is there a way to run /usr/bin/passwd so the password is updated automatically? (That way, I won't have to deal with /etc/shadow at all)

For example:

Code:

passwd username newpass
Instead of

Code:

passwd username
New UNIX password: <pw>
Retype new UNIX password: <pw>

Lastly, I looked at the stdin option: "--stdin read new tokens from stdin (root only)"

Is there a way to run passwd --stdin username and then send the new password to passwd through a script?

Thanks in advance.

glalejos 01-16-2005 03:20 AM

Hi,

I'm not used to deal with passwords, but it seems that they are encrypted using the crypt() function (see crypt(3) manual page), wich implements the DES algorithm.

I don't know what do you mean with:
Quote:

Also, is there a way to run /usr/bin/passwd so the password is updated automatically? (That way, I won't have to deal with /etc/shadow at all)
I haven't found the "--stdin" option in passwd.

LouisR 01-16-2005 03:23 AM

Quote:

Originally posted by glalejos
Hi,

I'm not used to deal with passwords, but it seems that they are encrypted using the crypt() function (see crypt(3) manual page), wich implements the DES algorithm.

I don't know what do you mean with:

I haven't found the "--stdin" option in passwd.

Thanks, I'll look into the crypt function.

What distro are you using? I'm running FC3. Check http://unixhelp.ed.ac.uk/CGI/man-cgi?passwd for more info... it includes the --stdin thing.

glalejos 01-16-2005 10:41 AM

I'm using Debian SID, and I'm almost sure that the man page of passwd of my distribution doesn't say a word about the --stdin option.

LouisR 01-16-2005 12:45 PM

Quote:

Originally posted by glalejos
I'm using Debian SID, and I'm almost sure that the man page of passwd of my distribution doesn't say a word about the --stdin option.
Maybe your version of passwd is different, because I know mine does. I'm running FC3.


All times are GMT -5. The time now is 01:44 PM.