Mário Gamito
2008-May-16 08:38 UTC
[CentOS] [OT]: Passing password for a command on the fly
Hi, First things first, sorry for the off-topic, but I've already burned my eyes Googling and couldn't find the answer to what I need and I remembered asking here, because I'm a long time CentOS and its mailing list user. Again, my apologies. I have this command to create an FTP account: # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/mario This command asks for the password twice. I need to pass the password (preferably without expect) so I can create the account without prompting. If i run: # echo secret | pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/gamito It reads the first insertion, but asks for the second. I knew how to do this a long time ago, but I've forgotten and couldn't find anything useful on Google. Any help would be appreciated. Warm Regards, M?rio Gamito
Luciano Rocha
2008-May-16 08:42 UTC
[CentOS] [OT]: Passing password for a command on the fly
On Fri, May 16, 2008 at 09:38:17AM +0100, M?rio Gamito wrote:> Hi, > > First things first, sorry for the off-topic, but I've already burned > my eyes Googling and couldn't find the answer to what I need and I > remembered asking here, because I'm a long time CentOS and its mailing > list user. > Again, my apologies. > > I have this command to create an FTP account: > > # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/mario > > This command asks for the password twice. > > I need to pass the password (preferably without expect) so I can > create the account without prompting. > > If i run: > > # echo secret | pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d > /home/pages/gamito > > It reads the first insertion, but asks for the second.(echo secret; echo secret) | pure-pw ... Or: echo -e 'secret\nsecret' | pure-pw Or: pure-pw <<EOF secret secret EOF -- lfr 0/0 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20080516/76c5bfe8/attachment-0005.sig>
El 16/05/2008, a las 10:38, M?rio Gamito escribi?:> I have this command to create an FTP account: > > # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/ > mario > > This command asks for the password twice. > > I need to pass the password (preferably without expect) so I can > create the account without prompting. > > If i run: > > # echo secret | pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d > /home/pages/gamito > > It reads the first insertion, but asks for the second.Dear Mario, I have the same problem some days ago, try with this: ( echo ${PASSWORD} ; echo ${PASSWORD} ) | pure-pw useradd ${USUARIO} - u ftpuser -g ftpgroup -d /backup/${USUARIO} -N ${QUOTA} -m > /dev/ null 2>&1 From the FAQ at: http://pureftpd.sourceforge.net/FAQ "* Passwords and pure-pw scripting." ===================================================================-> I would like to create virtual users with a shell-script. if i us pure-pw useradd ..... it always asks for the new password. is there any command-line option which tells pure-pw the password (like useradd ftp-user ftp-password -m) ? (at1ce) . Giving cleartext (and badly one-way hashed) passwords through command- line switches is a bad idea. Because users could issue a simple 'ps' command and discover these passwords. One way to enter a password (not from the keyboard) is to put the password twice in a temporary file, then redirect that file to stdin. Example: pure-pw useradd john -d /tmp/john -u ftpuser -m < ~/tmp/passfile And in ~/tmp/passfile, have something like: john's password john's password If you really need to avoid a temporary file and if nobody but you can log on the machine, you can always do this: (echo blahblah; echo blahblah) | pure-pw useradd john -d /tmp/john -u ftpuser =================================================================== Regards, -- Santi Saez Hostalia Internet S.L.U. http://www.hostalia.com
Mário Gamito
2008-May-16 08:47 UTC
[CentOS] [OT]: Passing password for a command on the fly
Dear Luciano (aka strange), Thank you very nice :) Kind Regards, M?rio Gamito On Fri, May 16, 2008 at 9:42 AM, Luciano Rocha <strange at nsk.no-ip.org> wrote:> On Fri, May 16, 2008 at 09:38:17AM +0100, M?rio Gamito wrote: >> Hi, >> >> First things first, sorry for the off-topic, but I've already burned >> my eyes Googling and couldn't find the answer to what I need and I >> remembered asking here, because I'm a long time CentOS and its mailing >> list user. >> Again, my apologies. >> >> I have this command to create an FTP account: >> >> # pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d /home/pages/mario >> >> This command asks for the password twice. >> >> I need to pass the password (preferably without expect) so I can >> create the account without prompting. >> >> If i run: >> >> # echo secret | pure-pw useradd mario -u 502 -g 502 -n 1000 -N 200 -d >> /home/pages/gamito >> >> It reads the first insertion, but asks for the second. > (echo secret; echo secret) | pure-pw ... > > Or: echo -e 'secret\nsecret' | pure-pw > > Or: pure-pw <<EOF > secret > secret > EOF > > -- > lfr > 0/0 > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos > >