How do I migrate users passwords? I want to migrate some users from my Drupal 7 installation to a new Drupal 8 installation. I do not want to migrate the whole site or any content. And I also do not want to migrate all users.

The problem is the password; I can export from Drupal 7 and import users to Drupal 8, but the passwords do not work anymore. I've also tried to update the hashes (password) in the database directly; so I copied the password fields from Drupal 7 to Drupal 8. That also doesn't work; I think the salt changed in Drupal 8.

Is there any solution for this?
Sorry for the confusion. Clarification:

Copying over the hashes from D7 to D8 works (I made a mistake with a backslash in the JSON output)!

So just copy over the D7 hashes (starting with $S$) from the D7.users.pass field to the D8.users_field_data.pass field. It will work. The first time, that the users logs in to the new D8 site, the password gets rehashed with the D8 algorithm (PhpassHashedPassword.check() and PhpassHashedPassword.needsRehash() are doing the magic).

Everything is fine :-) Thanks.

EDIT: Someone requested the code for this... 

Here is my controller class that imports all the Drupal 7 users found in the file asde2.users.json:

  public function importAsde2Users() {
    // load asde2 user file
    $usersfile = $_SERVER['DOCUMENT_ROOT']."/".drupal_get_path('module', 'preosuser')."/asde2.users.json";
    PxLog::debug($this, "Loading asde2 users file ".$usersfile);
    // decode json array of objects
    $users = json_decode(file_get_contents($usersfile));
    PxLog::debug($this, "Found ".count($users)." Users in that file");
    $database = \Drupal::database();
    // import all of them
    foreach ($users as $user) {
      $newuser = \Drupal\user\Entity\User::create([
          'name' =&gt; $user-&gt;name,
          'pass' =&gt; $user-&gt;pass,
          'mail' =&gt; $user-&gt;mail,
          'status' =&gt; $user-&gt;status,
          'init' =&gt; $user-&gt;init,
          'created' =&gt; $user-&gt;created,
          'login' =&gt; $user-&gt;login,
          'access' =&gt; $user-&gt;access,
          'uid' =&gt; $user-&gt;uid,
        ]);
      $newuser-&gt;addRole("xx");
      $newuser-&gt;addRole("yy");
      $newuser-&gt;save();
      // dirty overwrite re-hashed hash
      $database-&gt;merge('users_field_data')
        -&gt;fields(['pass' =&gt; $user-&gt;pass])
        -&gt;keys(array('uid' =&gt; $user-&gt;uid))
        -&gt;execute();
    }

    return ['#markup' =&gt; "Created ".count($users)." Users with that file", '#cache' =&gt; ['max-age' =&gt; 0]];
  }


Have fun.