Skip to content

Instantly share code, notes, and snippets.

@markallenpark
Created June 17, 2022 23:29
Show Gist options
  • Save markallenpark/9ab3918aa869b961809e5f04eb024871 to your computer and use it in GitHub Desktop.
Save markallenpark/9ab3918aa869b961809e5f04eb024871 to your computer and use it in GitHub Desktop.
Generate password hash for including in cloud-init scripts
#!/bin/env python3
import crypt
from getpass import getpass
print('Generate password hash\n\n----\n')
password = getpass('Password: ')
password_confirm = getpass('Confirm Password: ')
print('\n')
if password == password_confirm:
print('Passwords match!\n\n----\n')
print('Hash: ' + crypt.crypt(password) + '\n')
else:
print("Passwords don't match!\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment