[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Offtopic: Setting Passwords



Bill, thanx for the input.  It's not too different from what I
have worked up, but it's always helpful to look at alternate
solutions.  As soon as I can put a full package together, I'll
send you my version.
	Mike

At 02:33 PM 9/15/1999 +0200, Bill Tihen -- TECHNOLOGY wrote:
>Yes I got several good answers, my favorite was:
>
>useradd username
>echo "username:password:uid:gid:Full Name:path:shell" | newusers
>echo "Full.Name:\t\tusername" >> /etc/aliases
>
>I however used:
>
>useradd username -c "Full Name"
>echo "username:password:::::" | newusers
>echo "Full.Name:\t\tusername" >> /etc/aliases
>
>Just keep the correct number of : and everything will be okay.
>
>I wrote another script to extract the information from a file and
automatically generate passwords and then it wrote the above script for the
accounts it follows (this script also generates a lyx file, but I never
found out how to easily print them -- next time I will create postscript or
latex files -- I know there are converters for all this stuff, but know one
could tell me how to generate the paperwork easily -- oh well):
>
>#!/usr/bin/perl
>
># output the following to a file (students.sh):
>#	#!/bin/sh
>#	cp /etc/aliases /etc/aliases.bak
># 	
>
># loop throught the file with student names
>
># 	read next line of student file
>#	student file should have the following format:
>#	"Lastname; Firstname","YOG"<CR>
>
># 	parse each line of the student file (tab deliminated)
>
># 	output each line to a file with the following format:
>#	useradd lastfirs -c "Firstname Lastname -- YOG"
>#	cat "firstname.lastname:	lastfirs" >> /etc/aliases
>
># go to next line in student file
>
># output:
>#	newaliases
>
>
># initialize the random number generator.
>srand(time ^ $$ ^ unpack "%32L", `ps axww | gzip`);	
>
># create list of valid password characters
>@chars = ("A" .. "Z", "a" .. "z", 0 .. 9, qw(! # $ % ^ & * , . ? - _ +));
>
>print "Enter the current year of graduation YYYY: ";
>$date = <STDIN>;
>chomp($date);
>
>open (OUTPUT, '>students.sh') || die "Couldn't open output file";
>
>print OUTPUT <<Headers;
>#!/bin/bash;
>cp /etc/aliases /etc/aliases.bak
>
>Headers
>
>open (INFILE, '<Students.txt') || die "Couldn't read input file";
>while (<INFILE>) {
>	chomp ($_);
>	($Longname, $Advisor, $yog) = split(/","/,$_);
>
>	$Longname =~ s/;/,/;		# convert ; into , 
>	$Longname =~ s/"//g;		# remove quotes
>	$Advisor =~ s/"//g;
>	$yog =~ s/"//g;			
>	($Lastname, $Firstname) = split (/,/, $Longname);
>	$Firstname =~ s/ //;		# leading (1st) space
>	$last = $Lastname;
>	$first = $Firstname;
>	$last =~ s/([^\W0-9_])/\l$1/g;	# make lowercase
>	$first =~ s/([^\W0-9_])/\l$1/g;	
>	$last =~ s/ /-/g;		# replace spaces with dashes
>	$first =~ s/ /-/g;		
>	$slast = $last;			# create short names
>	$sfirst = $first;
>	$slast =~ s/-//g;		# remove dashes
>	$sfirst =~ s/-//g;
>	$slast = substr($slast, 0, 4);	# make 4 characters long
>	$sfirst = substr($sfirst, 0, 4);
>	$sname = $slast.$sfirst;
>	if ($yog > $date) {		# if not a pg 
>		$yog = $yog - 1;	# then subtract 1 from yog
>	}				# problem from rediker
>	
>	# generate random password
>	$password = join ("", @chars[ map { rand @chars } ( 1 .. 10) ]);
>	
>	# concatonate the random characters
>	
>	print OUTPUT <<Commands;
>/usr/sbin/useradd $sname -c "$Longname -- $yog"
>/bin/echo "$first.$last:\\t\\t\\t$sname" >> /etc/aliases
>/bin/echo "$sname\:$password\:\:\:\:\:" | newusers
>
>Commands
>
>$filename = "Explain/".$sname."\.lyx";
>
>open (ACCOUNT, ">$filename");
>
>	print ACCOUNT <<ExplainAccount;
>#This file was created by <bill> Tue Sep  7 21:25:54 1999
>#LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team
>\\lyxformat 2.15
>\\textclass article
>\\language default
>\\inputencoding default
>\\fontscheme default
>\\graphics default
>\\paperfontsize default
>\\spacing single 
>\\papersize a4paper
>\\paperpackage a4
>\\use_geometry 0
>\\use_amsmath 0
>\\paperorientation portrait
>\\secnumdepth 3
>\\tocdepth 3
>\\paragraph_separation indent
>\\defskip medskip
>\\quotes_language english
>\\quotes_times 2
>\\papercolumns 1
>\\papersides 1
>\\paperpagestyle default
>
>\\layout Title
>
>$Longname
>\\layout Author
>
>Advisor: $Advisor
>\\layout Description
>
>Login: $sname
>\\layout Description
>
>e-mail: $first.$last\@tasis.ch
>\\layout Description
>
>SMTP-Server: mail.tasis.ch
>\\layout Description
>
>POP-Server: mail.tasis.ch
>\\layout Description
>
>IMAP-Server: mail.tasis.ch
>\\layout Description
>
>Password0: $password
>\\layout Description
>
>Password1: _____________________
>\\layout Description
>
>Password2: _____________________
>\\layout Description
>
>Password3: _____________________
>\\layout Description
>
>Password4: _____________________
>\\layout Description
>
>Password5: _____________________
>\\layout Standard
>
>
>\\emph on 
>New passwords
>\\emph default 
>: 
>\\layout Itemize
>
>must not be in any dictionary.
>\\layout Itemize
>
>must be at least 10 characters long.
>\\layout Itemize
>
>must have at least 
>\\series bold 
>one
>\\series default 
> symbol or number.
>\\layout Itemize
>
>should not be based on your birthday, address, etc.
> or those of your relatives.
>\\the_end
>ExplainAccount
>
>close ACCOUNT;
>
>	}
>	
>close OUTPUT;
>close INPUT;
>
>exit(0);
>	
>
>