From owner-freebsd-questions Sun Oct 6 15: 7:27 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A55F837B401 for ; Sun, 6 Oct 2002 15:07:25 -0700 (PDT) Received: from lurza.secnetix.de (lurza.secnetix.de [212.66.1.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 902C843E4A for ; Sun, 6 Oct 2002 15:07:24 -0700 (PDT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [IPv6:::1]) by lurza.secnetix.de (8.12.5/8.12.5) with ESMTP id g96M7NmC056868 for ; Mon, 7 Oct 2002 00:07:23 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.12.5/8.12.5/Submit) id g96M7NgO056867; Mon, 7 Oct 2002 00:07:23 +0200 (CEST) Date: Mon, 7 Oct 2002 00:07:23 +0200 (CEST) Message-Id: <200210062207.g96M7NgO056867@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG Reply-To: freebsd-questions@FreeBSD.ORG Subject: Re: /dev/urandom is randomly cool In-Reply-To: <20021006172402.M71117-100000@earl-grey.cloud9.net> X-Newsgroups: list.freebsd-questions User-Agent: tin/1.5.4-20000523 ("1959") (UNIX) (FreeBSD/4.6-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Leftwich wrote: > On Sun, 6 Oct 2002, Fernando Gleiser wrote: > > On Sun, 6 Oct 2002, Mikko Työläjärvi wrote: > > > tr -cd a-zA-Z0-9 < /dev/urandom | dd bs=$len count=1 2>/dev/null > > It didn't work. My shell is tcsh so I tried: > tr -cd a-zA-Z0-9 < /dev/urandom | dd bs=8 count=1 >& /dev/null > And all I got was the next prompt. Yep, csh and tcsh suck pretty much. Not being able to separately redirect stderr easily is one of the reasons. In this particular case, you can use head instead of dd: tr -cd a-zA-Z0-9 < /dev/urandom | head -c 8 If your intention is to generate passwords, then you should also include special characters, not just letters and digits. I once wrote a small shell script to generate good passwords: http://www.secnetix.de/~olli/scripts/genpwd After installing it somwhere in yout $PATH (for example in /usr/local/bin) and making it executable, type "genpwd -h" for usage information. It also uses /dev/urandom, if it exists, but it also works fine without -- you can easily remove that part from the script (three lines) and it will still work with sufficient randomness, without having to touch your kernel's entropy pool. BTW, the script can also be (ab)used for other things. There are two examples in the usage message. Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message