Add user problem
What's up!Everyone. :D
My question is that how can I add a user and set his/her password in one command line on Linux.I've tried -p option but it ain't work.Is that password being encrypted?? Any help is appreciated. ;) |
Code:
adduser <name>; echo "<passwd>" | passwd <name> --stdin |
Stupid...
Thanks for your reply iceman47.However,how stupid that I am!I don't understand your code.Would you mind telling me in an example?
Quote:
|
i think this should work...
log in as root suppose u wanna add a user called 'swift'..then issue the following command.. useradd swift; passwd swift then it will prompt u twice for the password.... |
Thanks,coolamit78.However,I intended to do it via PHP script with exec() function.So,I want to do this in "one" command line without any further prompt.
Thanks for all you guys every efforts to help me out.:D |
well....the -p option that is used with the useradd command needs an encrypted password, so u cant provide this password directly as it wouldnt be possible for u to perform the encryption manually. Therefore, u have to achieve this in some other indirect way. I am not in a position to suggest u anything right now....I'll sure, post a reply later after I try to do that with a single command..
good luck |
Re: Stupid...
Quote:
Code:
adduser iceman; echo "letmein" | passwd iceman --stdin |
It worksssssssssssss!!!!!!
Wow,thanks a lot iceman47.It works!!!Thank you so much! ;)
|
I did £¡ And it works £¡ ¹ş¹ş thanks everyone£¡
|
adduser iceman; echo "letmein" | passwd iceman --stdin
Ok....i agree that this command rocks.....but I havent understood it entirely... Now here, the output of echo is piped to the passwd command (this is what --stdin is actually doing....it takes the input as if it was coming through the standard input) Now my question is....whenever we give the command 'passwd', it prompts us 2 times to enter the password. But here, the piped output of echo is just one out of the total 2 times....then how come it does not ask for password rentry?? pls clarify.. thanks |
Quote:
|
New problem....
It's me again.. :D Anyway,back to the problem.
Indeed,this script works fine when I execute it via command line (PHP).But what I exactly wanna do is when someone signs up,it will automatically add a user on my server.However,this script can only be executed by ROOT.Indeed,it's somehow very dangerous...:rolleyes: My question is,how can I run this script in a more secure way/how to run it as ROOT? Many thanks. ;) |
dude... NOT SAFE.
You're basically allowing *everyone* user-level access to the system... How do you mean, "when someone signs up"... Signs up how? While you rethink that, read up on the setuid utility for executing the script. Code:
man setuid |
What I mean...
dude,thanks for your reply. :)
What I mean is that when someone signs up as my website's member,I want my system automatically adds them to my server.So I don't have to do it on my own everytime. Do you know what I mean?Thanks. :D |
I take it you want to let people register a uid and password for your site -
|
All times are GMT -5. The time now is 10:19 PM. |