Is there any way in which I can set the password for a newly created user account in AIX in a one line command?
I don't want to give any prompt to the user. If there is a command, it should set the password to that user without asking anything on the screen.
I need to use that command in another technology like Java/.Net. I need to create the accounts with password on a AIX machine at run time by executing one line of code where I can pass parameters.
Suppose a user is giving a username in the text box of a Java application and in the background the command needs to be executed which will create the user accounts(with the password) at a remote AIX server. I am successful to add a user account, but setting the password is something where I am stuck.
Add a comment
|
1 Answer
You can use chpasswd
The chpasswd command administers users' passwords. The root user can supply or change users' passwords specified through standard input. Each line of input must be of the following format.
username:password Only root users can set passwords with this command.
Example 1:
echo username:password | chpasswd
Example 2:
Also for security you can pass encrypted password to chpasswd
# Create Password in Encrpyted Form Using below command
# perl -e'print crypt("YourPassword", "salt")' ; echo -e
echo username:cryptedPass | chpasswd -e
-
@tbp_09 can you please accept ans as correct :)Rahul Patil– Rahul Patil2013-09-25 14:47:44 +00:00Commented Sep 25, 2013 at 14:47
-
Any idea how can I do the same thing for su command. Assume I have a root password and i want to change to root mode without giving any prompt so that i can run/invoke scripts from remote server using java or .netatp9– atp92013-10-01 13:54:16 +00:00Commented Oct 1, 2013 at 13:54
-
have take look at expect tool nist.gov/el/msid/expect.cfmRahul Patil– Rahul Patil2013-10-01 14:06:52 +00:00Commented Oct 1, 2013 at 14:06
-
also check some su trick in this link vladz.devzero.fr/002_su-stdin.phpRahul Patil– Rahul Patil2013-10-01 14:21:42 +00:00Commented Oct 1, 2013 at 14:21
-
Thanks for suggesting vladz.devzero.fr/002_su-stdin.php I can try something like that.atp9– atp92013-10-03 13:53:58 +00:00Commented Oct 3, 2013 at 13:53