Re: Creating password for command on the fly

"Adam T. Bowen" <[email protected]>
Newsgroups org.kernel.vger.linux-admin
Message-ID <[email protected]>
Hi,

Mário Gamito wrote:
> I have this command to create an FTP account:
> 
> # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/gamito
> 
> This command asks for the password twice.

It's a shame it doesn't allow you to pass in a password on the command 
line, like the UNIX useradd command, but hey ho.

I wouldn't bother using the pure-pw command, and would modify the 
/etc/pureftpd.passwd file manually.  I had a quick look at the 
documentation and it seems you have to make sure you rebuild the passwd 
database to commit any changes with:

pure-pw mkdb

if you manually edit it.  There is a description of the passwd file 
format in the documentation.  Here is an extract:

---------------------------------------------------------
You can also edit the files by hand if you want.

Files storing virtual users have one line per user. These lines have the
following syntax:

<account>:<password>:<uid>:<gid>:<gecos>:<home directory>:<upload
bandwidth>:<download bandwidth>:<upload ratio>:<download ratio>:<max 
number of connections>:<files quota>:<size quota>:<authorized local 
IPs>:<refused local IPs>:<authorized client IPs>:<refused client 
IPs>:<time restrictions>

Fields can be left empty (exceptions: account, password, uid, gid, home
directory) .
---------------------------------------------------------

Alternatively, you may be able to do something like:

echo "password\npassword" | pure-pw useradd ...

but I don't run or have the pure ftp stuff installed, so I can't promise 
that that will work.  Depends on how the command reads input from stdin.

Hope that helps

Cheers

Adam
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFILU/nfNJVASeK9ugRAgdoAKCOJ8gutVDRdgvk0em640Z4y0bKUACfcR8n
XBcs60kOizAR5+jKKvo99W0=
=FnM4
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.