nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

How to add a user to redhat ??????

This is a discussion on How to add a user to redhat ?????? within the Shell scripting forums, part of the Development/Scripting category; I have used adduser command with various options to add a user. And it is also get replect in /etc/passwd ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-17-2007, 03:34 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Rep Power: 0
praveenmall
Default How to add a user to redhat ??????

I have used adduser command with various options to add a user. And it is also get replect in
/etc/passwd file. But whenever I login it says that incorrect username or password.

Is there any shellscript for that ?????
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-17-2007, 04:41 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Rep Power: 0
praveenmall
Default

I have written the code like that :::::
user is added but I m not able to login.


echo "enter the name of user "
read user;
echo " enter the user id"
read uid;
echo " enter the group id"
read gid;
echo "enter the home directory"
read home
echo "enter the shell script"
read shell
echo "enter the password"
read password
grep $user /etc/passwd > /dev/null
if [ $? -eq 0 ]; then
adduser -u $uid -g $gid -d $home -s $shell -p $password $user
else
echo "$user already exist"
fi
Reply With Quote
  #3 (permalink)  
Old 03-18-2007, 09:52 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Rep Power: 0
narasimha.reddygnv
Default hii we have got the same error on fedora 6

the answer is in the user accounts u need to remove the authentication ..
search the comand/icon in linux //
the problem can be rectified
Reply With Quote
  #4 (permalink)  
Old 03-20-2007, 11:59 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Rep Power: 0
praveenmall
Default No such command like icon

I go for command icon in Redhat but no manual entry for this command. If you have
written the shell script for deleting user the definitely u wld have been having shell
script for adding user. And u wd have been logged in to the system after adding user.

Please le me know in detail.
Reply With Quote
  #5 (permalink)  
Old 03-20-2007, 10:16 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You need to pass the encrypted password, as returned by crypt. The default is to disable the account. What you are passing is cleartext. Use perl to generate password:

Perl code
Code:
rPasswd=$(perl -e 'print crypt($ARGV[0], "Az")' $password)
Script to add user with encrypted password:
Code:
#/bin/bash
echo "enter the name of user "
read user;
echo " enter the user id"
read uid;
echo " enter the group id"
read gid;
echo "enter the home directory"
read home
echo "enter the shell script"
read shell
echo "enter the password"
read password
grep $user /etc/passwd > /dev/null
if [ $? -eq 0 ]; then
rPasswd=$(perl -e 'print crypt($ARGV[0], "Az")' $password) 
adduser -u $uid -g $gid -d $home -s $shell -p $rPasswd $user
else
echo "$user already exist"
fi
Use above script.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #6 (permalink)  
Old 03-21-2007, 01:05 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Rep Power: 0
praveenmall
Default Thank u very much

Thanks a lot
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Add normal user / FTP user usein NORMAL user(non-root) anilvrathod Shell scripting 0 12-07-2007 07:04 PM
how to enable a user and disabling a user narasimha.reddygnv Shell scripting 1 03-31-2007 01:31 AM


All times are GMT +5.5. The time now is 06:08 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36