Visit Jeremy's Blog.
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-02-2014, 05:14 AM   #1
Registered: Jul 2013
Posts: 44

Rep: Reputation: Disabled
useradd command with -p option (cannot login to new account)

Hi. I've tried creating a new user account with custom options and everything works fine except for the password. I couldn't login when I created a password using the "-p {password} option. I had to login as a different user and change the password with the sudo passwd {username} command.
Old 06-02-2014, 06:45 AM   #2
Registered: Mar 2013
Posts: 622

Rep: Reputation: 136Reputation: 136
As stated in the useradd manpage:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3).
Use the passwd command to set/change the users password.

You could also create a small binary yourself using the crypt() function.
Old 06-02-2014, 06:50 AM   #3
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 2,477

Rep: Reputation: Disabled
You'll have to encrypt the password first and then pass the hash to useradd with the -p option. You can use openssl to generate the hash/salt:
user@linux:~$ openssl passwd -1 SecretPassword
user@linux:~$ sudo useradd -p $1$9tYqclBf$dW1jWQVk.9FEck02WLrc3. newuser
The user newuser will now be able to log on with the password SecretPassword.
Old 06-02-2014, 07:00 AM   #4
Registered: Jul 2013
Posts: 44

Original Poster
Rep: Reputation: Disabled
Ok.I read something on the encryption but wasn't certain. Thanks !


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
[SOLVED] SSH - How can I only allow a key pair login for my user account not root account? shanekelly Linux - Security 5 01-25-2013 10:45 AM
useradd -r option and system account question macogala Linux - Newbie 6 07-23-2011 04:04 AM
Eee PC 1000 Linux Laptop - Just setup a login account for privacy, now can't login!!! martinkettle Linux - Laptop and Netbook 3 10-28-2008 06:21 AM
useradd - question about --non-unique option cygnus-x1 Linux - General 2 02-27-2008 11:57 AM
useradd:'invalid user name' error when creating a machine account on RedHat Linux ES4 santosh0805 Linux - General 1 07-12-2005 09:39 AM > Forums > Linux Forums > Linux - Newbie

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