2
def createUser(username,password):
    password = crypt.crypt(password,"$5$a1")
    os.system("sudo useradd -p '#{password}' -m "+username)

    createUser("lesson1",idhash)

This is the code I have for creating user accounts so far, but each time the user account is created the password that is inserted in the method definition is not the password for the newly created account.

1
  • You're not using the password variable. Commented Jun 25, 2017 at 23:42

1 Answer 1

1

Fix the following line to use username and password:

os.system("sudo useradd -p {} -m {}".format(password, username))
Sign up to request clarification or add additional context in comments.

12 Comments

Try cleartext password first, if it works then there is an issue with your idhash variable
i also changed the password to plain text and am still receiving the "invalid password" error
You are getting the error when creating the user or when trying to login?
when trying to login
That is normal, because when creating users with useradd, you need to provide an encrypted password. Now check the value of idhash
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.