Register
It is currently Wed Apr 23, 2014 6:26 am

Script to add user and group and change pass non-interactive


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Fri Oct 03, 2008 5:52 pm   
User avatar

Joined: Fri Oct 03, 2008 5:48 pm
Posts: 8
I would highly appreciate anyone who can create the following script...

The script I need will be called like
./scriptname username password
and I need it to then add the user, create a group with the same name as the username and change the password to that supplied.
I am on an Ubuntu system if that info is needed.

I plan to add this script to the beginning of another script I have. The resulting script will make my life a heck of a lot easier. The only issue im having is the adding user, adding group and changing password in that manner.

Again, I would highly appreciate anyone who can create this much needed script.

Thank you


Top
 Profile  
 PostPosted: Fri Oct 03, 2008 6:19 pm   
User avatar

Joined: Sun Apr 13, 2008 4:05 am
Posts: 37
Location: /dev/random
Code:
#!/bin/bash
groupadd  $1
password=$2
pass=$(perl -e 'print crypt($ARGV[0], "salt")' $password)
useradd  $1 -g $1 -p $pass

something like this. you need perl to execute it. sudo may needed on ubuntu.


Top
 Profile  
 PostPosted: Fri Oct 03, 2008 6:21 pm   
User avatar

Joined: Fri Oct 03, 2008 5:48 pm
Posts: 8
I also would like to ask if someone can help me with editing one line from a file...

The "resulting script" mentioned in my first post will also need to edit /home/jail/etc/passwd (the /etc/passwd on the system will remain unedited)...

from:
username:x:1001:1001:,,,:/home/jail/./home/username:/usr/sbin/jk_chrootsh

to:
username:x:1001:1001:,,,:/home/jail/./home/username:/bin/bash

where the 1001 will be different and the username will be the username passed via ./scriptname username password


Top
 Profile  
 PostPosted: Fri Oct 03, 2008 6:40 pm   
User avatar

Joined: Sun Apr 13, 2008 4:05 am
Posts: 37
Location: /dev/random
this is not a cracking related forum. also you may need permisson to change that file. if it is your system why do ya need to use fakeroot :P


Top
 Profile  
 PostPosted: Fri Oct 03, 2008 6:46 pm   
User avatar

Joined: Fri Oct 03, 2008 5:48 pm
Posts: 8
Quote:
this is not a cracking related forum. also you may need permisson to change that file. if it is your system why do ya need to use fakeroot Razz

I'm creating a jail environment for ssh users. However I will likely be needing to add users every so often and it's a lot of commands to add a user. I know a little bit about bash scripting but am having issues with the editing of that one file and originally the creating user.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP