Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- man 1 passwd
- --stdin
- This option is used to indicate that passwd should read the new
- password from standard input, which can be a pipe.
- adduser "$1"
- echo "$2" | passwd "$1" --stdin
- #!/usr/bin/perl -w
- open my $pipe, '|chpasswd' or die "can't open pipe: $!";
- print {$pipe} "$username:$password";
- close $pipe
- echo $mypassword | passwd --stdin # Eternal Sin.
- echo "$mypassword" | passwd --stdin # Eternal Sin, but at least you remembered to quote your PE.
- passwd --stdin <<< "$mypassword" # A little less insecure, still pretty insecure, though.
- passwd --stdin < "passwordfile" # With a password file that was created with a secure `umask(1)`, a little bit secure.
- user="$1"
- password="$2"
- adduser $user
- echo $password | passwd --stdin $user
Add Comment
Please, Sign In to add comment