LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-20-2008, 10:58 PM   #1
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Rep: Reputation: 17
useradd problem


I am newbie here. I want to useradd in my system. I have tried adduser and useradd.both succesfully done. Now i wana try useradd with the arguments.How to useradd with the password also.

man for useradd with password is -p

so i did this, but its not working

useradd -p password test.

user test will be created, but when i want to login with the user test, it tells authentication failure. sorry

How to useradd with password as its arguments.?

Thank you
 
Old 02-20-2008, 11:14 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Tha argument for -p is an excrypted password not plaintext. Is this what you gave

Quote:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the account.
 
Old 02-20-2008, 11:18 PM   #3
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
hurmmm!!!! what i did was actually

useradd -p 123 john

123 is my password
john is my login

so how should I do it

Thank You
 
Old 02-20-2008, 11:31 PM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Don't know off th top of my head. You should be able to use slappaswwd if you have ldap installed, but there must be a simpler way.

Any reason not to just add the user then run passwd?
 
Old 02-20-2008, 11:56 PM   #5
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
hurm....the reason is, just wanted to try. I can do teh passwd after creating the user, but just curious
 
Old 02-21-2008, 12:56 AM   #6
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
in the man useradd. what does this mean

-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the account.
 
Old 02-21-2008, 01:33 AM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
It means you can use either -p or --password to specify the password option for useradd (this is pretty common that short option names only require one "-" and long versions require two - not hard and fast rule through).

crypt() is a C function from what I can tell that returns a DES encrypted password that won't look anything likt the 123 that you were trying to use above.
 
Old 02-21-2008, 01:42 AM   #8
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
that means there is no way I can do this " useradd -p 123 john " to add password for the user.
THat means how its actually done is

useradd -p "the encrypted password" john
 
Old 02-21-2008, 02:34 AM   #9
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
Ok if that is the case, how am i goin to encrpyt the password??
 
Old 02-21-2008, 07:03 AM   #10
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
As I said, you can use something like spapasswd, but I'm sure there are standalone generators around. I don't think you can use passwd though

What is your objective here. You can add the user an automate the passwd process using --stdin if you need to
 
Old 02-21-2008, 09:59 AM   #11
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
automate the passwd process using --stdin. How do i do it actually. I am not sure --stdin. I want to have a script that can have 2 user inputs, that means getting username and password. I dont want to put (usr/bin/passwd $username) in the script because after executing the script it will ask 2 enter the password. I want the password entered in the script to be used. Thats y i used useradd -p mypassword username, but it does not work for the password part..Please help
 
Old 02-21-2008, 11:57 AM   #12
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Original Poster
Rep: Reputation: 17
I have found a website http://www.mail-archive.com/linux-in.../msg18943.html

it says we can use

useradd $username
echo $passwd | passwd --stdin $username

I dun understand the shell script above. I am more familiar with perl script only. DIf i add the script above to make it complete, is it like this, please check my script in shell

#!/bin/bash

echo -n enter username
read username
useradd username
echo $passwd | passwd --stdin $username

Please help.
 
Old 02-21-2008, 04:19 PM   #13
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Perhaps chpasswd will do what you want. This was actually pretty hard to find, but I assuem it's on mist systems. haven't looked at mine.

Last edited by billymayday; 02-21-2008 at 04:23 PM.
 
Old 02-21-2008, 04:23 PM   #14
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Or you could try something like this

http://vinhlg.vcomtech.net/blog/2007...to-the-system/
 
Old 02-21-2008, 11:29 PM   #15
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Easiest way I've found is to use OpenSSL directly, e.g.:

openssl passwd foobar

will return a password hash for foobar (the salt is chosen randomly, IIRC). If you want to use MD5 passwords you can add the -1 flag.
 
  


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
Useradd - Cannot locate /etc/default/useradd in Solaris Paean Solaris / OpenSolaris 4 12-09-2005 02:36 AM
useradd problem ruben0076 Linux - Newbie 4 01-11-2005 12:28 PM
useradd problem efanning Linux - Newbie 1 07-29-2004 08:24 PM
useradd problem giovannym Linux - Newbie 4 06-23-2004 08:59 PM
useradd Problem deepakjena_2003 Linux - Newbie 2 01-19-2004 09:21 AM


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

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