LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-18-2003, 10:28 PM   #1
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Rep: Reputation: 15
Question User adding scripts?


just wondering, I'm working on a script that add users requesting shell accounts to a system by having the user login as "newuser" which runs the script. But with my novice script programming skills, the only script I"m able to write for this task must run with some root permissions leaveing large sercurity holes in the system, with all that said, has anyone seen any scripts or programs for easiely adding users?
 
Old 11-19-2003, 12:45 AM   #2
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Do you mean 'ssh' logins?

I have a script that easily adds users, but, you must be root, your not going to find a script to add users that doesnt run as root, we'll you might, but its not advised.

The script is at http://www.ccsi.com/~stratus, its called 'useradd.sh', instructions for use are inside the file.

As for running it as a user, you can always allow a group of users by looking into 'sudoers', 'sudo' and 'visudo'.

Tarts

Last edited by Tarts; 11-19-2003 at 12:46 AM.
 
Old 11-19-2003, 09:36 PM   #3
evilchild
Member
 
Registered: Sep 2003
Location: 127.0.0.1
Distribution: *bsd, solaris, gentoo
Posts: 86

Original Poster
Rep: Reputation: 15
thanks man, but thats not really what i'm looking for i think more user friendly for the users who dont know any thing about arguments
some thing like this

#!/bin/bash

username=" "
clear
echo "Welcome to n3tlab. this program will help you add an account to our system"

echo "What would you like your username to be?"
read username

if test -e /home/$username
then

echo "sorry but that username is in use, please choose another"
read username
echo "now to change your password"
passwd $username
echo "your account has been succesfully created to start using it telnet to us then login with your new account name"
echo "thank you for using n3tlab"
logout

else

echo "ok, your username is $username"
echo "now to change your password"
passwd $username
echo "Your account has succesfully been created, to begin using it telnet to us and login with your account name"
echo "thank you for using n3tlab"
logout
fi

#done

but i need to know a way to make the script work better, with my skills it will only test to see if the user is taken once then, if the user inputs another used username it will try to add the username any ways, can some one help me out with this?
 
Old 11-21-2003, 08:49 AM   #4
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
I dont know how you plan on using it, but here:

Code:
#!/bin/bash
SUCESS=
PASS=
username=" "
clear
echo "Welcome to n3tlab. this program will help you add an account to our system"

echo "What would you like your username to be?"
read username

if test -e /home/$username; then
   SUCESS=1
fi

while [ "$SUCESS" = 1 ]
do
  echo "sorry but that username is in use, please choose another"
  read username
  if ! test -e /home/$username; then
    SUCESS=0
  fi
done
echo "choose a password, minimum 8 charators"
read TMP
while [ ${#TMP} -lt 7 ] || [ ${#TMP} -gt 50 ]
do
  if [ ${#TMP} -lt 7 ]; then
    echo "The password needs to be greater than 8 characters" 
    echo "Please input your password..."
  elif [ ${#TMP} -gt 50 ]; then
    echo "Your password needs to be less 50 characters..."
    echo "Please input your password..."
  fi
  read TMP
done
PASS=$(openssl passwd -1 "$TMP")
useradd -p "$PASS" "$username"
echo "your account has been succesfully created to start using it telnet to us then login with your new account name"
echo "thank you for using n3tlab"
logout
exit 0
#done
Tarts

Last edited by Tarts; 11-22-2003 at 08:55 PM.
 
  


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
Adding Startup Scripts kaplan71 SUSE / openSUSE 1 08-25-2005 10:52 PM
adding bootsplash scripts to bootup? microsoft/linux Debian 7 12-17-2004 09:44 AM
Adding startup scripts etcetera Linux - Software 1 12-16-2004 08:19 AM
User Specific Startup scripts carbonnb Linux - Newbie 2 07-02-2003 06:33 PM
Changing user scripts? Nerd2 Programming 12 05-22-2003 09:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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