LinuxQuestions.org
Register a domain and help support LQ
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 06-22-2006, 07:53 PM   #1
cramer
Member
 
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, 08:01 PM   #2
twantrd
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.

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

Rep: Reputation: 59
Quote:
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.
Code:
(adduser fred ; mkpasswd fred)

or

(adduser fred ; mkpasswd -p passwd fred)
# note: passwd is a command, not a password
 
Old 06-22-2006, 10:10 PM   #4
cramer
Member
 
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, 11:50 PM   #5
cramer
Member
 
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

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

Shell script:

Code:
#!/bin/sh

# 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:
Code:
#!/usr/bin/expect


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


Reply


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


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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration