[PYTHON] That of / etc / shadow

gen-shadowpass.py


from crypt import crypt

method_num = 6  # SHA-512
salt = "chihaya" # 
password = input("password: ")

print(crypt(password, "${num}${salt}".format(num=method_num, salt=salt)))

Run in Shell

$ python3 gen-shadowpass.py
password:Anything is fine
$6$chihaya$moeYHfUnBzrGnBo0qcZ.ExPeYgFtjIFhc8BR1jnE.1DMXU7waByCOVSOY2vY3qwOh9BHybqZ84nY/8tQLGrnk/

You can forcibly change the password by writing the above character string in / etc / shadow. Ubuntu 12.04 seems to use 8 characters for salt. Well, I don't think anyone would do that.

Recommended Posts

That of / etc / shadow
Progress of 5/6 ~ C arrangement etc. ~
Note: Modify / etc / shadow directly
Samples of Python getters, setters, etc.
This and that of python properties
This and that of the inclusion notation.
Imaging of neural networks that recognize MNIST
Automation of server monitoring etc. with Monit