Import password hash I'm trying to migrate users from a non Drupal System into Drupal. I implemented my own CSV import script which basically generates Drupal user entities.

I already managed to teach Drupal how to handle the password hashes from the old system so that on first login of an "old" user, the old hash is getting replaced with a new one.

When creating a user account, Drupal automatically hashes the input for the Password field. I guess this is happening in the post save hook of the user entity.

How can I create user entities which will have my old hash inside of the pass field?
I figured it out by myself now. In case someone runs into the same problem:
Updating the database directly avoids the problem of rehashing:

$query = \Drupal::database()-&gt;update('users_field_data')-&gt;fields([
    'pass' =&gt;$prefixed_password_hash,
])-&gt;condition('uid',$user-&gt;id());

$query-&gt;execute();