User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,441 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 7738 | Replies: 0 | Solved
Reply
Join Date: Oct 2007
Posts: 31
Reputation: DemonSpeeding is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
DemonSpeeding DemonSpeeding is offline Offline
Light Poster

Help Creating a user in Linux without adduser/useradd

  #1  
Oct 26th, 2007
This is my first time writing a bash script in Linux, basically I want to create a user but not use adduser or useradd.
So, in the /etc/passwd folder I need to put data in, in this way.
login:encrypted passwd:UID:GID:gecos:home directory:login shell
I'm going to leave the gecos blank.

Then I need to do something with the /etc/shadow folder, something with the encrypted password, adding it to it.

And finally, giving the person the startup files and doing a chmod to them, maybe 700 or 711, I'm not sure the difference. Also I know cp copies in Linux, but I don't know what startup files should be given to the user.

#!/bin/bash
# This script will set up a user account.
echo "What do you want your account name to be?"
read login
echo "What do you want your password to be?"
read password
char *crypt(const char *password, const char *salt);
hdirectory = mkdir /home/$login
shell = /bin/bash

I'm at a standstill, I need to find the last used UID and add 1 to it, and I guess I'll make that the GID too. I've got the home directory made in the script, and the login shell. I'm sure you can also see I don't really know how to use crypt, I couldn't find a nice easy example anywhere, anytime I found an example I couldn't even see where they were encrypting something.

To add these things to /etc/passwd and etc/shadow would I just pipe it?
user = login:password:UID:GID::hdirectory:shell 
user | /etc/passwd
shadow = password 
shadow | /etc/shadow
Something like that?
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC