> 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/guides/setting-up-cli-ykman.md).

# Setting up CLI / ykman

Instructions on setting up the ykman command-line interface.

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FRN90BsLKoAV9icrgjHjv%2Fbanner_guide_cli.png?alt=media&amp;token=020b9e63-780d-4eaa-a4cd-b5335465a5b5" alt=""><figcaption></figcaption></figure>

CLI (command-line interface) is a great way of managing your Yubikey's PIV, OTP, FIDO, OATH, and GPG interfaces and the data it stores. It's an alternative way of managing your Yubikey rather than the ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**Yubikey Manager**](https://www.yubico.com/support/download/yubikey-manager/) software.

You may ask *"What's the difference?",* and there is a lot. The Yubikey Manager software is great, but it is severely limited. There's a whole world out there in the difference between what the Yubikey Manager will let you do, and the capabilities of the CLI called ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**ykman**](/yubikey5/guides/setting-up-cli-ykman.md).

## <mark style="color:red;">❊ How to Get</mark>

The command-line tool made for Yubikey is a program called ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**ykman**](https://developers.yubico.com/yubikey-manager/). It gets installed on your system when you download and install the ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [Yubikey Manager](https://www.yubico.com/support/download/yubikey-manager/). If you currently have the Yubikey Manager program installed, then you also have ykman.

## <mark style="color:red;">❊ Where is it?</mark>

The ykman CLI sits in the same folder as your Yubikey Manager program's exe file.

![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54)[Read the documentation provided by Yubico for a way to find this CLI depending on your Operating System which has been linked here.](https://docs.yubico.com/software/yubikey/tools/ykman/Using_the_ykman_CLI.html)

Open up your Command Prompt, Terminal, or Powershell application and execute the command below:

{% tabs %}
{% tab title="Windows" %}

```
cd "C:\Program Files\Yubico\YubiKey Manager\"
```

{% endtab %}

{% tab title="MacOS" %}

```
cd "/Applications/YubiKey Manager.app/Contents/MacOS/"
```

{% endtab %}
{% endtabs %}

## <mark style="color:red;">❊ Accessing ykman</mark>

If you want to run commands with ykman, you have two options:

1. Change to the directory where ykman.exe is every time you open Command Prompt, Terminal, or Powershell, *OR*;
2. Create an <mark style="color:red;">**`environment variable`**</mark> which allows you to open Command Prompt, Terminal, or Powershell and immediately start typing your command no matter what folder you are in.

### <mark style="color:blue;">Setting up Environment Variables (Windows)</mark>

Click ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FtBOD0vf1tSGu3t9OBfLn%2Ficon_windows_start.png?alt=media\&token=20b59251-c22a-47dd-a494-96f7aa08d052) and type <mark style="color:red;">**Environment**</mark>.

The option <mark style="color:red;">**Edit the system environment variables**</mark> should appear.

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FBY7QVBc4ZUx6nH8L1CVG%2Fenv_var_1.png?alt=media&amp;token=f330092e-2fc3-4ba6-80fa-d90b9e51b07f" alt=""><figcaption></figcaption></figure>

Once the dialog box appears on the <mark style="color:red;">**Advanced**</mark> tab, at the bottom, click ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FCSz3VGYxmEDIb7lCiavE%2Fenv_var_2.png?alt=media\&token=9650ed0c-8484-4fa8-9576-5ed39b1edbaa)

You should see two seperate boxes labeled **USER VARIABLES** and <mark style="color:red;">**SYSTEM VARIABLES**</mark>.

In the <mark style="color:red;">**System Variables**</mark> box, locate the line which defines **Path**.

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FR5tH6iR42NabcYIn6CLZ%2Fenv_var_4.png?alt=media&amp;token=8e83d83a-b5d9-4f0b-b9b2-42660c25633b" alt=""><figcaption></figcaption></figure>

Highlight the Path line and then click ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FDYeHZOUGqdhxqZsfxw2O%2Fenv_var_5.png?alt=media\&token=d97bfc11-387a-47a7-8df8-57759be8386f)

We need to add the Yubikey Manager directory as a new system variable.

Select ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FBj7rHOO3zQT1HrnpC20E%2Fenv_var_6.png?alt=media\&token=a6833bd1-3d4b-4960-a46d-52bd5bb525c8) on the right hand side of the new dialog window.

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FM8w2zHbtXAToJDhKMUCf%2Fenv_var_7.png?alt=media&amp;token=d368ee03-9a64-4bce-a371-eda0835a99e1" alt=""><figcaption></figcaption></figure>

You will notice a box open up at the very bottom of the window where you can type.

In the box, enter <mark style="color:yellow;">**`C:\Program Files\Yubico\YubiKey Manager`**</mark>

{% hint style="info" %}
While you're here, if you plan on using GPG with your Yubikey and are running Windows, you can also add:

<mark style="color:yellow;">`C:\Program Files (x86)\GnuPG\bin`</mark>
{% endhint %}

Once you enter the path to Yubikey Manager, you can click ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2F8oGFwpGj4yfXvNh8e17S%2Fenv_var_8.png?alt=media\&token=ee6cf4d9-44c6-4a0a-b413-3734c54b5d0f)

You have now created a System Environment Variable which will become extremely useful.

To test if it works, open Command Prompt, Terminal, or Powershell in a new window. You should start in your user's home folder which is C:\Users\yourusername.

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2F3E3icNuRoldfhVUtetF9%2Fenv_var_9.png?alt=media&amp;token=6983c69a-95f3-4580-8856-d3ada8af33f4" alt=""><figcaption></figcaption></figure>

In the box, simply type <mark style="color:yellow;">**`ykman`**</mark> and press enter.

You should see a large amount of text print in your window:

<figure><img src="https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FG8YrzCcMoBKyKv1lTKgZ%2Fenv_var_10.png?alt=media&amp;token=2aa8d5da-40ef-4a61-a039-4ee96799c11c" alt=""><figcaption></figcaption></figure>

If you see the output of ykman without being in the Yubikey Manager folder, that means your system environment variable is working. You can now run ykman commands from any folder.

This becomes extremely helpful and less annoying.

However, if you get any of the following:

```
The term 'ykman' is not recognized as a name of a cmdlet

'ykman' is not recognized as an internal or external command, operable program or batch file.
```

Go back to your system environment variables list again and confirm you typed the correct path. Open your File Manager and try to go to the folder <mark style="color:yellow;">**`C:\Program Files\Yubico\YubiKey Manager`**</mark>

If you do not see the folder at all, make sure you have ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**Yubikey Manager**](https://www.yubico.com/support/download/yubikey-manager/) installed.

Finally, try rebooting your system after confirming everything else.

If you had your Command Prompt or Powershell open before you added the environment variable, close it and open a new instance before trying to execute ykman so that the new variable changes can take effect.

## <mark style="color:red;">❊ Now What?</mark>

You have unlocked a whole new world of options on how you can configure your Yubikey.

We recommend checking out our ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**Setting up a New Key**](/yubikey5/guides/setting-up-a-new-key.md) guide to see if there's anything there you want to do.

You can also view our guide on ![](https://3439786616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFqFACNHWgp8HSNubDNCu%2Fuploads%2FvruVNIOWoWHUaDrROjUK%2Flink%20\(1\).png?alt=media\&token=8ac71312-243b-4852-999d-74eaa595ec54) [**Setting Up GPG**](/yubikey5/guides/setting-up-cli-gpg.md).
