Guest User

Untitled

a guest
Jun 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. man 1 passwd
  2.  
  3. --stdin
  4. This option is used to indicate that passwd should read the new
  5. password from standard input, which can be a pipe.
  6.  
  7. adduser "$1"
  8. echo "$2" | passwd "$1" --stdin
  9.  
  10. #!/usr/bin/perl -w
  11. open my $pipe, '|chpasswd' or die "can't open pipe: $!";
  12. print {$pipe} "$username:$password";
  13. close $pipe
  14.  
  15. echo $mypassword | passwd --stdin # Eternal Sin.
  16. echo "$mypassword" | passwd --stdin # Eternal Sin, but at least you remembered to quote your PE.
  17. passwd --stdin <<< "$mypassword" # A little less insecure, still pretty insecure, though.
  18. passwd --stdin < "passwordfile" # With a password file that was created with a secure `umask(1)`, a little bit secure.
  19.  
  20. user="$1"
  21. password="$2"
  22. adduser $user
  23. echo $password | passwd --stdin $user
Add Comment
Please, Sign In to add comment