Adding a user non-interactively?Forum: Networking Topic: Adding a user non-interactively? started by: johnbo Posted by johnbo on Jan. 13 2005,08:08
Hi,I've been following this forum for the last couple of days as I've been trying the DSL 0.9.2. I'm very impressed, both with DSL and the forum. I'm trying to build a box that will boot off a CD (easy), run a web server on fixed content (easy), and run an FTP server also with an initially fixed content (not so easy). There is no hardware, no USB, no display, no keyboard. Just a mini-ITX board, a CDROM and a network cable. This will eventually be used as a demo tool for our products. It appears that the problem that I'm running into (other than a minor shortage of Linux/Unix background), is that I need to have a specific username and password that is usable on the FTP server. If I create them using the UserAdd function in the menu's, everything is fine, but I can't do this at startup each time and I've read the warnings about trying to restore the various password file at startup. (I can't guarrentee that this will never have a hardisk installed). I've tried the useradd function in the shell, but it doesn't seem to generate a valid password (this is a guess). I'm trying to supply it with a cleartext password string for the new user. When I try to open an ftp session at localhost, the password is refused. I've also tried the adduser function in the shell. This will generate a valid user account, but will not run without user interaction (it prompts for various fields one of which is the passwd). At this point the only thing that I can think of is to write a simple C program that calls the 'crypt' function and use that to get my non-cleartext password value. Any thoughts? Thanks, johnbo Posted by cbagger01 on Jan. 13 2005,17:46
See these threads for help:< http://damnsmalllinux.org/cgi-bin....%shadow > < http://damnsmalllinux.org/cgi-bin....%shadow > < http://damnsmalllinux.org/cgi-bin....%shadow > Posted by johnbo on Jan. 13 2005,19:54
Thanks for the pointers. It was the last one in the list that pointed me in the right direction. What I found was that I used useradd to create the user, but not attempt to set up password. Then use chpasswd to set the password using clear text.
I had forgotten to mention that I had harvested ke4nt1's script to make the passwd type files writeable. This is what the enableuser.sh script is above. I couldn't find much documentation for chpasswd's input format, but eventually realized that it was looking for a file with lines like user:password in it. Thanks, johnbo Posted by roberts on Jan. 13 2005,20:41
I do not know of this script. But there has been the ability to addusers for ssh and ftp, thus making the appropriate files writeable, for a long time. The script already in DSL to make the files writeable is /etc/init.d/ssh_addusers Posted by johnbo on Jan. 14 2005,05:14
The script that I found on the forum, is pretty much exactly what is in the ssh_adduser script. Its always amazing what you can find when you know were to look.Thanks, johnbo |