Sponsored Content
Top Forums Shell Programming and Scripting Create new user account and password in shell script Post 302387982 by killuane on Tuesday 19th of January 2010 04:45:51 AM
Old 01-19-2010
On Solaris I have tried:

1) redirecting the input as follows:

Code:
passwd $NEW_USER_ID <<EOF
> $NEW_PASSWD
> $NEW_PASSWD
> EOF

but I get prompted to enter the password interactively:
New Password:
2) putting the passwords into a file

Code:
echo $NEW_PASSWD >> tempfile
echo $NEW_PASSWD >> tempfile

then tried to redirect the contents of that file into the passwd command:

Code:
passwd $NEW_USER_ID < `cat tempfile`

from which I get the error:
ksh: $NEW_PASSWD^J$NEW_PASSWD: cannot open
(the error actually shows the real password not the environment variable)

or:

Code:
passwd $NEW_USER_ID < tempfile

but again I get prompted to enter the password interactively:
New Password:
3) write a mini shell script:

Code:
sleep 1
echo $NEW_PASSWD
sleep 1
echo $NEW_PASSWD

then tried to execute that script and pipe the output to the passwd command:

Code:
./script | passwd $NEW_USER_ID

but again I get prompted to enter the password interactively:
New Password:
So, it looks to me like my attempts to redirect stdin to the passwd command are failing but I don't know any other way to do it.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

create or modify user account to have same access as root

Is there a way to create or better yet modify a user account so it has the same privs as root? (6 Replies)
Discussion started by: xadamz23
6 Replies

2. Solaris

how can I change user name and password , of account ?

passwd only changes the password but i need to change the user name tnx (5 Replies)
Discussion started by: umen
5 Replies

3. Solaris

How to create a new ftp user account with limited access..?

Hi All, I'm using solaris 2.8, and I want create a new ftp user account with the following restrictions: - Have only ftp access, no telnet or rlogin - Have restricted access to its home directory example /export/home/newuser - Deny access to any other directory. Thanks for your help, ... (6 Replies)
Discussion started by: Jeremy3
6 Replies

4. Filesystems, Disks and Memory

script to create multiple instances of a user account across LPAR's

My company has about 40 databases with each database in a different logical partition. Presently the SysAdmin person says it is necessary to create a user profile (login and password for each instance of databases on each LPAR. 1. Is it necessary that the user must be created in each LPAR? 2.... (1 Reply)
Discussion started by: kcampbell
1 Replies

5. Debian

password less login to root from a user account

hello friends, one user is created named "user1" I login as "user1" . Now when i do "su -" to be root user I have to give password for root . Is there any way through which we can skip giving the password to root. i.e. user1@work:~$ su - Password: xxxxxx work:~$ I don't want that... (1 Reply)
Discussion started by: pradeepreddy
1 Replies

6. Shell Programming and Scripting

Passing password when changing the user account

Hi All, I have one requirment.. I need to change my id to some sudo account in a server.. Actually our username/passwd will be stored in one gip file like below... $cat .a.gz #It's hidden file username passwd $ So I tried the below script to pass the password when i sudo to... (7 Replies)
Discussion started by: raghu.iv85
7 Replies

7. UNIX for Dummies Questions & Answers

block user account after failed password

hi guys I have Centos 5.4 The idea is lock the user account for 3 minutes after he has entered his password incorrectly 3 times. I've modified /etc/pam.d/system-auth auth required pam_tally.so onerr=fail per_user deny=3 account required pam_tally.so resetbesides... (3 Replies)
Discussion started by: kopper
3 Replies

8. Solaris

Help me create new user account

I want create user. That user should be login to any server without asking password. How? tell me in detail. :wall: (3 Replies)
Discussion started by: Navkreddy
3 Replies

9. Shell Programming and Scripting

Shell script for user account Creation

Hi Folks, I had a request to create the user request. Between, I just write a script a create, Update Geos, and update the password. My script as below: The error message, what I am getting is all the users are updated with the same Goes value.. #!/bin/bash for i in `cat users.txt`;do... (2 Replies)
Discussion started by: gsiva
2 Replies

10. UNIX for Beginners Questions & Answers

Create a shell script to gather user account information and displays the result to administrator

I want to create a shell script to gather user account information and displays the result to administrator. I have created a script but its showing all the information when i search for username like: amit@mx:~$ ./uinfo.sh amit Username : amit User Info ... (2 Replies)
Discussion started by: amit1986
2 Replies
USERMOD(8)						      System Manager's Manual							USERMOD(8)

NAME
usermod - Modify a user account SYNOPSIS
usermod [-c comment] [-d home_dir [-m]] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group [,...]] [-l login_name] [-p passwd] [-s shell] [-u uid [-o]] [-L|-U] login DESCRIPTION
The usermod command modifies the system account files to reflect the changes that are specified on the command line. The options which apply to the usermod command are: -c comment The new value of the user's password file comment field. It is normally modified using the chfn(1) utility. -d home_dir The user's new login directory. If the -m option is given the contents of the current home directory will be moved to the new home directory, which is created if it does not already exist. -e expire_date The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD. -f inactive_days The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of -1 disables the feature. The default value is -1. -g initial_group The group name or number of the user's new initial login group. The group name must exist. A group number must refer to an already existing group. The default group number is 1. -G group,[...] A list of supplementary groups which the user is also a member of. Each group is separated from the next by a comma, with no inter- vening whitespace. The groups are subject to the same restrictions as the group given with the -g option. If the user is currently a member of a group which is not listed, the user will be removed from the group -l login_name The name of the user will be changed from login to login_name. Nothing else is changed. In particular, the user's home directory name should probably be changed to reflect the new login name. -p passwd The encrypted password, as returned by crypt(3). -s shell The name of the user's new login shell. Setting this field to blank causes the system to select the default login shell. -u uid The numerical value of the user's ID. This value must be unique, unless the -o option is used. The value must be non-negative. Values between 0 and 99 are typically reserved for system accounts. Any files which the user owns and which are located in the directory tree rooted at the user's home directory will have the file user ID changed automatically. Files outside of the user's home directory must be altered manually. -L Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password. You can't use this option with -p or -U. -U Unlock a user's password. This removes the '!' in front of the encrypted password. You can't use this option with -p or -L. CAVEATS
usermod will not allow you to change the name of a user who is logged in. You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID is being changed. You must change the owner of any crontab files manually. You must change the owner of any at jobs manually. You must make any changes involving NIS on the NIS server. FILES
/etc/passwd - user account information /etc/shadow - secure user account information /etc/group - group information SEE ALSO
chfn(1), chsh(1), passwd(1), crypt(3), groupadd(8), groupdel(8), groupmod(8), useradd(8), userdel(8) AUTHOR
Julianne Frances Haugh (jockgrrl@ix.netcom.com) USERMOD(8)
All times are GMT -4. The time now is 02:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy