> For the complete documentation index, see [llms.txt](https://yubico.gitbook.io/yubikey5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yubico.gitbook.io/yubikey5/piv-1/commands/keys/export.md).

# export

Export a public key corresponding to a stored private key. This command uses several different mechanisms for exporting the public key corresponding to a stored private key.

## <mark style="color:red;">ykman piv</mark> keys export <mark style="color:red;">OPTIONS</mark> SLOT PUBLIC-KEY

<table><thead><tr><th width="284">Options</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:red;">-h, --help</mark></td><td>Show this message and exit.</td></tr><tr><td><mark style="color:red;">-F, --format [PEM|DER]</mark></td><td>Encoding format. <br>[default: <mark style="color:red;"><code>PEM</code></mark>]</td></tr><tr><td><mark style="color:red;">-P, --pin TEXT</mark></td><td>PIN code (used for <mark style="color:red;"><code>--verify</code></mark>).</td></tr><tr><td><mark style="color:red;">-v, --verify</mark></td><td>Verify that the public key matches the private key in the slot.</td></tr></tbody></table>

<table><thead><tr><th width="284">Arguments</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:red;">PUBLIC-KEY</mark></td><td>File containing the generated public key. <br>Use <mark style="color:red;"><code>-</code></mark> to use <mark style="color:red;"><code>stdout</code></mark>.</td></tr><tr><td><mark style="color:red;">SLOT</mark></td><td>PIV slot of the private key.</td></tr></tbody></table>

### <mark style="color:blue;">HELP</mark>

{% tabs %}
{% tab title="Help Command" %}

```properties
Usage: ykman.exe piv keys export [OPTIONS] SLOT PUBLIC-KEY

  Export a public key corresponding to a stored private key.

  This command uses several different mechanisms for exporting the public key corresponding to a stored private key, which may fail. If a
  certificate is stored in the slot it is assumed to contain the correct public key. If this is not the case, the wrong public key will be
  returned.

  The --verify flag can be used to verify that the public key being returned matches the private key, by using the slot to create and verify a
  signature. This may require the PIN to be provided.

  SLOT        PIV slot of the private key.
  PUBLIC-KEY  File containing the generated public key. Use '-' to use stdout.

Options:
  -F, --format [PEM|DER]  Encoding format.  [default: PEM]
  -v, --verify            Verify that the public key matches the private key in the slot.
  -P, --pin TEXT          PIN code (used for --verify).
  -h, --help              Show this message and exit.
```

{% endtab %}
{% endtabs %}

### <mark style="color:blue;">EXAMPLE</mark>

{% tabs %}
{% tab title="example 1" %}

```
```

{% endtab %}
{% endtabs %}
