# How to Migrate WebAuthn (YubiKey) Credentials Between Keycloak Instances

**URL:** <https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266>\
**Category:** Getting advice\
**Tags:** authentication\
**Created:** [February 2, 2026, 6:44pm UTC](https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266 "2026-02-02T18:44:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spudweb](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@spudweb](https://forum.keycloak.org/u/spudweb)\
**Post date:** [February 2, 2026, 6:44pm UTC](https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266/1 "2026-02-02T18:44:03Z")

</div>

Hello Keycloak community,

I’m facing a challenge migrating a user with a WebAuthn (YubiKey) credential between two identical Keycloak instances (`test1.company.dev` and `test2.company.dev`). Both instances are configured with the same RPID/sub-domain for WebAuthn policies.

**Problem:**

1. I registered a YubiKey for a user on `test1.company.dev`, and it works correctly.

2. I exported this user’s data into a users.json file (including their password and `webauthn-passwordless` credentials).

3. I performed a partial realm import of this user into `test2.company.dev` via the Admin API. The user and both their credentials appear in the `test2` admin console.

4. However, when I try to log in to `test2` with the YubiKey, I get errors saying that the YubiKey isn’t connected or is connected to a different user.

**My Understanding & Suspicions:**

It seems the `credentialId` of the WebAuthn token might be strongly tied to Keycloak’s internal `user.id`. Even though I’m importing the user with the same `id` from the source instance, the target instance might be having a conflict or mismatch in this internal mapping.

**Specific Questions:**

1. Is the user’s `id` from the import JSON directly linked to the WebAuthn `credentialId` in a way that causes this conflict during migration?

2. What is the recommended, robust method for programmatically migrating users with existing WebAuthn credentials between identical Keycloak instances?

3. Are there specific fields within the WebAuthn credential data (e.g., the `id` field for the credential, `counter`) that need special handling or omission during such an import?

4. Could this error suggest a `credentialId` collision in `test2.dev`’s database, possibly from a prior failed attempt?

Any insights or best practices for ensuring smooth WebAuthn credential migration would be highly appreciated. My goal is to avoid requiring users to re-register their YubiKeys when moving between Keycloak environments.  
Note that I am operating in a highly partitioned environment and so need to have multiple instances of KC running separately and then manually sync. This is the part of the manual sync that I am having problems smoketesting.

Thank you!

User Credentials Format that I am using:  
{

“id”: “SOME\_HASH”,

“type”: “webauthn-passwordless”,

“createdDate”: 1764194058611,

“secretData”: “{}”,

“credentialData”: “{\“aaguid\”:\“00000000-0000-0000-0000-000000000000\”,\“credentialId\”:\“COPIED\_FROM\_TEST1.COMPANY.DEV\”,\“counter\”:5,\“credentialPublicKey\”:\“COPIED\_FROM\_TEST1.COMPANY.DEV\”,\“attestationStatementFormat\”:\“none\”,\“transports\”:[\“usb\”]}”

```
    }

  \]

```

---

<div class="post-metadata">

**Author:** ![robson90](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/robson90/32/12479_2.png) [@robson90](https://forum.keycloak.org/u/robson90)\
**Post date:** [February 19, 2026, 10:45am UTC](https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266/2 "2026-02-19T10:45:36Z")

</div>

When Im not mistaking, the Credential is bound to the DNS name.

You can check with this plugin: [https://chromewebstore.google.com/detail/webauthn-devtools/ogpaejcbmlcjnkcbnfmdfheifgodnnec](https://chromewebstore.google.com/detail/webauthn-devtools/ogpaejcbmlcjnkcbnfmdfheifgodnnec)

When I check my Keycloak instance on my Homeserver, Keycloak is calling credentials.get() with payload:  
{  
“rpId”: “keycloak.\<MY\_DOMAIN\>”,  
“challenge”: “Am\_0QdXOR2Wc…..”,  
“userVerification”: “required”  
}

The response does contain the origin, which is my Keycloak domain.

From a little bit of googling and checking the Keycloak config, you should be able to do this: [Passkeys and custom domains | Okta Developer](https://developer.okta.com/docs/guides/custom-passkeys/main/#configure-an-rp-id)  
Add your `company.dev`as the rpId. Keycloak → Authentication → Policies → Webauthn Passwordless Policy → Relying Party ID

You will probably need to recreate your passkey afterwards, but migration should in theory work. I have not had this scenario.

Would be nice, if you come back and share your experience !

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [February 19, 2026, 8:06pm UTC](https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266/3 "2026-02-19T20:06:41Z")

</div>

> [@robson90](#):
>
> When Im not mistaking, the Credential is bound to the DNS name.

Correct. Passkeys (Fido2 Webauthn Keys, or however you call them), are domain-bound. That’s the main feature to make them phishing-resistant. The browser will only suggest and offer to use the keys of the current domain. Other keys MUST NOT being able to use.  
While it’s possible to issue keys to multiple domains, it’s not possible to extend the valid domains afterwards. Once the key is created, it’s immutable.  
So, if you switch domains, the current keys become useless/invalid.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/keycloak/original/1X/eb342909d95cf32cbb7517610022c6a0046a9ffb.png) [@system](https://forum.keycloak.org/u/system)\
**Post date:** [August 18, 2026, 8:06pm UTC](https://forum.keycloak.org/t/how-to-migrate-webauthn-yubikey-credentials-between-keycloak-instances/31266/4 "2026-08-18T20:06:58Z")

</div>

Closed on August 18, 2026, 8:06pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
