give password with command /usr/sbin/passwd
Everytime the server reboots I want to create a user at boot. For some reason I loose my user after a reboot.
So I thought I'd create a script that creates this user (in rc.local for example) Therefore I need to give the password directly with the command /usr/bin/passwd. I can't find in the man-page how a password can immediately be given with the command... |
Hm, im not to sure..
Perhaps auto making an entry in /etc/passwd would do it? Would look something like this: james:K3xcO1Qnx8LFN:1000:1000:,,,1-800-FOOBAR:/home/james:/bin/bash The "K3xcO1Qnx8LFN" bit being the encrypted pass. |
Quote:
Code:
useradd my-user -p `mkpasswd mypasswd` |
First of all you should find out why you lose your user when your box reboots
You can use newusers to do what you want. Create a file.txt like this: Code:
username:password:XXXX:YYY::/home/user:/bin/bash and then run on boot: Code:
/usr/sbin/newusers /path/to/file.txt |
I put /usr/sbin/useradd my-user in rc.local but my user is not created ?!
When I run /usr/sbin/useradd my-user from commandline, then the user is created... |
Try adding these 2 lines to /etc/rc.local
useradd $USER echo password | passwd --stdin $USER replace $USER with reqd username |
Quote:
Code:
[root@box]# cat /etc/passwd | grep user I just can't get this user created at startup... |
I think we need to backtrack.
1. can you create a new user and passwd after you have logged in as root? ie no errors. show contents of /etc/passwd, /etc/shadow If not, show error msgs 2. If create went ok, can you then login as that user? If not, show error msgs |
Quote:
/usr/sbin/useradd my-user and then everything is fine... don't even need a password. It is still intact... Code:
[root@box]# cat /etc/passwd | grep user Still don't understand why placing "/usr/sbin/useradd my-user" in rc.local is not enough... as it IS enough on commandline. rc.local is executed as root-user, right ?! |
All times are GMT -5. The time now is 03:47 PM. |