LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-27-2009, 02:12 PM   #1
knockout_artist
Member
 
Registered: Sep 2005
Distribution: fedora core 9
Posts: 324

Rep: Reputation: 33
Creating password hash.


Hi,

I need to create password hash. Reason I need it so I can use it to create user account with one line "useradd" command.
Some thing like this.

#useradd username -p <hash>

What I have found out is

"makepasswd"
is different as it use to be ??
What I found on the Internet makepasswd seems like it has what I need.

Code:


makepasswd(1)                UNIX Reference Manual               makepasswd(1)

NAME
       makepasswd - generate and/or encrypt passwords

SYNOPSIS
       makepasswd [ --chars N ] [ --clearfrom file ] [ --count N ] [ --crypt |
       --nocrypt | --crypt-md5 ] [ --cryptsalt N ] [ --help ] [ --maxchars N ]
       [ --minchars N ] [ --randomseed N ] [ --rerandom N ] [ --repeatpass N ]
       [ --string string ] [ --verbose | --noverbose ]

DESCRIPTION
       makepasswd generates true random passwords  by  using  the  /dev/random
       feature  of Linux, with the emphasis on security over pronounceability.
       It can also encrypt plaintext passwords given on the command line.

OPTIONS
       --chars N
              Generate passwords with exactly N characters (do  not  use  with
              options --minchars and --maxchars).

       --clearfrom FILE
              Use   password   from  FILE  instead  of  generating  passwords.
              Requires the --crypt or the --crypt-md5 options; may not be used
              with  these  options:  --chars, --maxchars, --minchars, --count,
              --string, --nocrypt.  Trailing newlines are  removed  but  other
              white space is not.

       --count N
              Produce a total of N passwords (the default is one).

       --crypt
              Produce encrypted passwords.

       --crypt-md5
              Produce  encrypted  passwords  using the MD5 digest (hash) algo-
              rithm.


<TRIMMED>


But I was only able to find makepasswd from freashmeat.org. Afetr installing it what I have is

Code:
$ makepasswd --help
Usage: makepasswd [option [value]] ...
	-c, --chars	string of allowed characters (A..Za..z0..9)
	-e, --encrypt	encryption algorithm {none,des,md5,shmd5} (none)
	-l, --length	password length
	-M, --max	password maximum length (8)
	-m, --min	password minimum length (8)
	-n, --number	number of passwords to generate (1)
	-p, --password	password to use
	-s, --salt	salt to use (random)
	-h, --help	display this help screen
	-V, --version	display program version
Its not the same utility.


Any suggestion about,

1-where to find real makepasswd.
2-If not, how do I get password hash exactly the way it looks in "/etc/shadow" file.

Thanks

Last edited by knockout_artist; 10-27-2009 at 02:13 PM.
 
Old 10-27-2009, 02:27 PM   #2
iambryan
LQ Newbie
 
Registered: Aug 2009
Location: Calgary, AB
Posts: 2

Rep: Reputation: 0
In RedHat I accomplish the scripting of user passwords in the following way (with an externally generated password as $pass):

pass=1234abcd
echo $pass | sudo passwd --stdin $username > /dev/null

Hope this helps

Bryan
 
Old 11-02-2009, 10:27 PM   #3
spindler
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
I have the same problem. In my case I'm trying to generate password hashes that are suitable for Unix when a user logs into a web portal, but I don't want to create local accounts.
 
Old 11-02-2009, 11:33 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Commands like useradd will generate appropriately hashed password-values where and when they are needed. You don't supply the hashed values yourself.

Hashed passwords are normally calculated using algorithms such as sha1 or (less commonly these days) md5. Functions to produce them are readily available in whatever is your language of choice.
 
Old 11-04-2009, 06:49 AM   #5
spindler
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
useradd doesn't really work as that does local account management. Think a web portal where a user creates an account and as they are granted privileges accounts are created for them on various machines. For security reasons you don't want to keep their password around, instead you want to create the appropriate password hashes that you might need later. Generic MD5 doesn't work b/c the password hash is salted and has some other odd bits done to it. I managed to find a perl module that would generate it for me so I'm good.
 
  


Reply



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 hash evil_empire Linux - Security 4 04-25-2009 07:16 AM
Restoring Password Hash zok Linux - Server 3 04-29-2008 12:22 PM
What type of password hash is this ? memo007 Linux - Security 7 12-26-2007 02:34 AM
Password Hash Query aml1973 Linux - Security 1 12-03-2007 07:50 AM
Change Password Hash Algorithm Trano Linux - Security 1 08-23-2005 07:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:05 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