LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 07-28-2011, 09:46 AM   #1
akuma_linux
Member
 
Registered: Aug 2006
Distribution: Ubuntu, CentOS
Posts: 31

Rep: Reputation: 15
useradd -p & crypt()


Hi all,

I'm attempting to write a small test script to take two variables (user name and password) from user input, encrypt the password variable then add the user to the linux system using useradd -p. The usage for useradd -p requires a password already encrypted with crypt(), however I am unsure of the usage for crypt (even after reading the man page). Could anybody offer any advice please?

I believe the script should look something like this (which doesn't work!) :

Code:
#!/bin/bash

echo "Enter user : "
read USER

echo "Enter password : "
read PASS

ENCRYPTEDPASS=crypt($PASS)

useradd -p $ENCRYPTEDPASS $USER

exit
Thanks in advance.
 
Old 07-28-2011, 10:59 AM   #2
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

I think you will find out what you're looking for
here
or some man here
 
Old 07-29-2011, 03:01 AM   #3
akuma_linux
Member
 
Registered: Aug 2006
Distribution: Ubuntu, CentOS
Posts: 31

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by lithos View Post
Hi,

I think you will find out what you're looking for
here
or some man here
Thanks very much for your reply. Out of interest, is there no way to do this without having to invoke the crypt command within perl?
 
  


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
useradd command to create passwd, shadow & other files under different directory rramesh1 Linux - Newbie 2 05-20-2011 07:26 AM
info about useradd & /etc/skel working with existing home folder andrea_g90 Linux From Scratch 5 05-11-2011 06:41 AM
useradd & smbpasswd using shell script ramecare Linux - Server 5 04-06-2011 01:57 AM
what is difference b/t useradd & adduser ram_rajavarapu Linux - Enterprise 1 07-25-2009 10:41 AM
useradd & dot usernames amigodm Slackware 8 03-19-2003 10:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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