Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-22-2006, 06:53 PM   #1
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

Rep: Reputation: 15
mkpasswd on RH9

I'm running Red Hat 9 shrike and am using the adduser command to create a user. I want to use mkpasswd to pre-encrypt the password that I send to the -p option of adduser.

Here is the problem. On other posts in this forum I see the command to be something like this to encrypt the password using mkpasswd:

adduser -p "`mkpasswd passwordhere`" username

However, using mkpasswd and then placing the password to be encrypted after it does not function the same on Red Hat as I see it does on other Linux systems. By adding that on the end of mkpasswd it thinks that is the username you are trying to set the password for, and gives you a username not found error.

How do I encrypt the password for the -p option of adduser?

Please help.
Old 06-22-2006, 07:01 PM   #2
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Why not just use 'passwd <account>'? It will hash the password in the shadow file.

Old 06-22-2006, 07:22 PM   #3
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
adduser -p "`mkpasswd passwordhere`" username
I agree with twantrd on that but, if you still want to use the mkpasswd command...
You might ask yourself "Why am I using a command to generate a password and still trying to put one in manually ... ( mkpasswd passwordhere ) ????

This is the command that works for me.
(adduser fred ; mkpasswd fred)


(adduser fred ; mkpasswd -p passwd fred)
# note: passwd is a command, not a password
Old 06-22-2006, 09:10 PM   #4
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

Original Poster
Rep: Reputation: 15
I am using it in a shell script so therefore I don't want it to prompt the user for input.
Old 06-22-2006, 10:50 PM   #5
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

Original Poster
Rep: Reputation: 15
Solved. I fixed it by doing this:

Shell script:


# Add client to server

adduser -m $1
passwd.exp $1 $2 >> /passwd_logs/log.txt
The passwd.exp is an expect script called in the shell script. This is the expect script which I used:

spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof


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
mkpasswd with FC4 cramer Linux - Newbie 5 06-16-2006 09:20 PM
mkpasswd in Debian swmok Debian 4 06-05-2005 07:30 PM
mkpasswd/group? vickr1z Linux - Newbie 0 09-23-2004 02:52 PM
mkpasswd LinuxRam Linux - Security 1 08-24-2004 03:24 AM
mkpasswd gadfly Slackware 2 09-13-2003 09:26 PM > Forums > Linux Forums > Linux - Newbie

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

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