<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_tty_password(confirm):
 """When returning a password from a TTY we assume a user is entering it on a keyboard so we ask for confirmation."""

    LOG.debug("Reading password from TTY")
    new_password = getpass('Enter Password: ', stream=sys.stderr)
    if not new_password:
        raise aomi.exceptions.AomiCommand("Must specify a password")

    if not confirm:
        return new_password

    confirm_password = getpass('Again, Please: ', stream=sys.stderr)
    if confirm_password != new_password:
        raise aomi.exceptions.AomiCommand("Passwords do not match")

    return new_password