LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-19-2004, 01:58 PM   #1
myhato
LQ Newbie
 
Registered: Aug 2004
Location: San Jose
Posts: 5

Rep: Reputation: 0
command line to set a password to a new userid


I need to write a script to create a new userid in a Linux environment.
That's done. Now i like to set a password for this userid, note that i want to do it in a script , not from a command line.

I had:
useradd -d /home/mht mht
I used crypt to create a new password and used the command:
usermod -p "encrypted password" mht.

This doesn't work. I saw in the /etc/shadow , other id has encrypted password starting with $. I guess my password is from crypt so it won't work. How do i encrypt my password so it can be copied to the command usermod -p.
 
Old 08-19-2004, 03:57 PM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
Re: command line to set a password to a new userid

Quote:
Originally posted by myhato
How do i encrypt my password so it can be copied to the command usermod -p.
I don't think you can.......the shadow program encrypts passwords that are already stored in
/etc/passwd file..........
 
Old 08-19-2004, 07:58 PM   #3
jimrt
Member
 
Registered: Mar 2003
Posts: 32

Rep: Reputation: 15
You can (I think) use openssl to encrypt your password.

Pipe the password through openssl: openssl passwd -1 -stdin

Example:

echo password | openssl passwd -1 -stdin

I tried this, and it seemed to work....

useradd test -p `echo test | openssl passwd -1 -stdin`
 
Old 08-19-2004, 11:46 PM   #4
myhato
LQ Newbie
 
Registered: Aug 2004
Location: San Jose
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by jimrt
You can (I think) use openssl to encrypt your password.

Pipe the password through openssl: openssl passwd -1 -stdin

Example:

echo password | openssl passwd -1 -stdin

I tried this, and it seemed to work....

useradd test -p `echo test | openssl passwd -1 -stdin`

This is great. It works fine. Thanks.
 
  


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
Can you specift password on SSH command line? The_JinJ Linux - Newbie 4 07-26-2005 05:55 AM
Command Line Password Check jedediah Linux - Security 4 12-09-2004 03:01 PM
Command-line 'adduser': password not hashing Talesin Fedora 0 10-08-2004 08:19 PM
written command line password generator lepricaun Programming 6 08-11-2004 12:36 AM
going to root without password thru command line amanjsingh Linux - Newbie 6 03-29-2004 11:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:08 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
Open Source Consulting | Domain Registration