Guest User

Untitled

a guest
May 5th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. The following procedure prevents mysql passwords from showing up in your mysql or bash history.
  2.  
  3. ### Create random password
  4. // create random password with openssl
  5. $ openssl rand -base64 32 | head -c 16
  6. wZw0USspr+eTKFNQ
  7.  
  8. // create random password with python (more complex)
  9. $ python -c "import string;from random import choice; print ''.join([choice(string.ascii_letters + string.digits + string.punctuation) for i in range(16)])"
  10. lD#':_7vxZZW7Sm!
  11.  
  12. ### Create mysql pw hash from password
  13. $ python -c 'from hashlib import sha1; import getpass; print "*" + sha1(sha1(getpass.getpass("New MySQL Password:")).digest()).hexdigest()'
  14. New MySQL Password:<password input doesn't show>
  15. *64e48b3407dd769ba941a67fce1480f3caab35c8
  16.  
  17.  
  18. ### Use hash in mysql
  19. // add user
  20. mysql> create user 'username'@'server.lan' identified by password '*64e48b3407dd769ba941a67fce1480f3caab35c8';
  21. // change user pw
  22. mysql> update mysql.user set authentication_string='*64e48b3407dd769ba941a67fce1480f3caab35c8' where user="username";
Add Comment
Please, Sign In to add comment