Backup and Restore — YubiHSM 2 User Guide documentation (2024)

  • YubiHSM 2: Backup and Restore
  • View page source

The YubiHSM 2 supports encrypted export and import of objects using a symmetric AES-CCM based scheme.

The examples below assume the default authentication key (0x0001). If you use some other authentication key make sure that it has the capability put-wrap-key and has the correct delegated capabilities, otherwise you will get a wrong permissions for operation error.

You can perform these operations using:

  • YubiHSM Shell for backing up and restoring
  • YubiHSM Setup for backing up and restoring
  • YubiHSM Key Storage Provider for backing up and restoring certificate as well as private key.

In all three cases, the process is done by taking the following steps:

  1. Create a wrap key, call it wrapkey.
  2. Import wrapkey into the primary YubiHSM2.
  3. Export other objects in the primary YubiHSM2 using wrapkey.
  4. Import wrapkey into the backup YubiHSM2.
  5. Import the objects exported in step 3 into the backup YubiHSM2.

In order for a full backup to be successful, the following conditions need to be fulfilled (any object that does not fulfill these conditions is not exported):

  • wrapkey is accessible in all the domains the other objects are available in.
  • wrapkey has delegated capabilities that include all the capabilities any other object has.
  • wrapkey has the capabilities export-wrapped and import-wrapped.
  • All other objects have the capability exportable-under-wrap.

Backup and Restore Using YubiHSM Shell

Backup

Step 1:

For the purpose of this guide, we will start by generating an asymmetric key that we will then make a backup of.

$ yubihsm-shell -a generate-asymmetric-key -A rsa2048 --capabilities exportable-under-wrap, sign-pkcs, decrypt-pkcs...Generated Asymmetric key 0x6e77...

OBS: This will generate an asymmetric key accessible in all domains.

Step 2:

Start by getting a pseudo random number from the YubiHSM2 and store it in a file. This will be the wrap key.

$ yubihsm-shell -a get-pseudo-random --count=32--out=wrap.key

Important

The file wrap.key here contains the Wrap Key loaded into your YubiHSM in clear text. It should therefore be considered sensitive.

Step 3:

Import wrap.key into the primary YubiHSM2.

...yubihsm-shell -a put-wrap-key --capabilitiesexport-wrapped,import-wrapped --delegated=sign-pkcs,decrypt-pkcs,exportable-under-wrap --in=wrap.key...Stored Wrap key 0xd581

OBS: This will import a wrap key accessible in all domains.

Step 4:

Make an encrypted backup of the Asymmetric Key 0x6e77 in the file key_6e77.yhw.

yubihsm-shell -a get-wrapped --wrap-id=0xd581--object-id=0x6e77 -t asymmetric-key--out=key_6e77.yhw

Restore

This assumes a fresh device where you want to restore the previously backed up key 0x6e77.

Step 1:

Import the wrap key into the backup YubiHSM2.

$ yubihsm-shell -a put-wrap-key -A aes256-ccm-wrap -c export-wrapped,import-wrapped --delegated=sign-pkcs,decrypt-pkcs,exportable-under-wrap--in=wrap.key -i 0xd581...Stored Wrap key 0xd581
Step 2:

Import the Asymmetric key 0x6e77 into the backup YubiHEM2.

yubihsm-shell -a put-wrapped --wrap-id=0xd581 --in=key_6e77.yhw...Object imported as 0x6e77 of type asymmetric-key

Backup and Restore Using YubiHSM Setup

The YubiHSM 2 Setup Tool can be used to backup and restore all exportable objects simultaneously.

Backup

OBS: This assumes that a wrap key fulfilling all the conditions mentioned above already exists in the primary YubiHSM2. For the following command line examples, we will assume that such a key has ObjectID 0xd581.

$ yubihsm-setup dumpEnter the wrapping key ID to use for exporting objects: 0xd581...Successfully exported object Asymmetric with ID 0x6e77 to ./0x6e77.yhwAll done

Note

When creating a wrap key using yubihsm-setup with the subcommand ksp or ejbca, an option is presented to split the wrap key into shares to be held by different custodians. It would also be possible to set the minimum number of custodians required to reconstruct the wrap key.

Important

Split and reconstruction of the wrap key is done in the software (yubihsm-setup). The YubiHSM2 itself is not aware of such split or any shares.

Restore

Running the store command will import all *.yhw files in the current directory. If some of those files are not encrypted/wrapped with a wrap key that exists in the backup YubiHSM2, they will not be imported.

$ yubihsm-setup restore

Note

If the wrap key was split, the shares to reconstruct it will need to be provided in this step.

Backup and Restore Using YubiHSM KSP (Windows Only)

YubiHSM Key Storage Provider (KSP) enables backing up and restoring the keys managed using this tool.

Note

Microsoft Active Directory Certificate Services (ADCS) does not set the NCRYPT_ALLOW_EXPORT_FLAG when generating a key, either through the setup UI or the Install-ADCSCertificationAuthority PowerShell module.

When creating an ADCS root CA key using the YubiHSM 2, we add the exportable-under-wrap Capability by default. Backup and restore functionality is therefore available using the following manual processes.

  1. Identify Your Private Key Container Name
  2. Backup the Target Certificate
  3. Backup the Target Private Key
  4. Restore the Target Private Key
  5. Restore the Target Certificate

Identify Your Private Key Container Name

Step 1:

To view the currently installed certificates in the Local Machine “My” store, open an elevated command prompt/shell by using the certutil command.

PS1> certutil -store My
Step 2:

Find the target certificate in the list and then find its Key Container property. The Provider property should be the same as YubiHSM Key Storage Provider.

Step 3:

To identify the certificate, record the Cert Hash property.

Backup the Target Certificate

Using any available means (certmgr.msc, PowerShell, certutil), export the target certificate, but without the private key in DER format.

Note

The YubiHSM does not provide a mechanism for returning the raw private key to Windows, so generating a PKCS#12 container is not currently possible.

For example, to export the certificate in .crt format to a file named <Cert Hash>.crt, use the command.

PS1> certutil -split -store My <Cert Hash>.

Backup the Target Private Key

Export the target private key with the label property equal to the Key Container property.

Step 1:Use an Authentication Key with the export-wrapped capability set.
Step 2:Use the instructions for exporting a private key under wrap via yubihsm-shell (see Backup and Restore Using YubiHSM Shell).

Restore the Target Private Key

Import the target private key file to your backup YubiHSM.

Step 1:Use an Authentication Key with the import-wrapped capability set.
Step 2:Use the instructions for importing a private key under wrap via yubihsm-shell (see Backup and Restore Using YubiHSM Shell).

The imported key object should have the same Label property as the original object.

Restore the Target Certificate

Before the certificate is imported to the local machine, it does not have an associated private key.

Step 1:

Move the target certificate file generated as per Backup and Restore Using YubiHSM Shell to the target machine by importing the certificate to the LocalMachine “My” store. Use your preferred method.

Step 2:

Re-associate the certificate to the private key by using the -repairstore functionality of certutil.

Step 3:

Verify that the target private key is visible via the YubiHSM KSP: list all private keys (and their corresponding container names - which are equal to the Label property in the YubiHSM visible to the current Authentication Key).

PS1> certutil -key -csp "YubiHSM Key Storage Provider"
Step 4:

Open an elevated prompt and execute the command:

PS1> certutil -repairstore MY <Cert Hash>
Step 5:

To verify that the certificate has been associated with the YubiHSM Key Storage Provider and has the correct Key Container property value, repeat the steps under Identify Your Private Key Container Name.

Backup and Restore — YubiHSM 2 User Guide  documentation (2024)

FAQs

How to backup and restore Active Directory step by step guide? ›

Procedure
  1. From the navigation pane, go to Protect > Active Directory. ...
  2. In the Name column, click the Active Directory server. ...
  3. In the row for the subclient, click the action button. ...
  4. In the Backup options dialog box, choose the backup options: ...
  5. Click OK.
  6. To view the backup history, click the action button.
Aug 2, 2024

What is the default password for YubiHSM 2? ›

The YubiHSM 2 device comes with a single factory-installed authentication key whose default password is password .

How to backup Active Directory users and computers in Windows 2012 R2? ›

Perform a backup with Windows Server Backup
  1. Open Server Manager, select Tools, and then select Windows Server Backup.
  2. If you're prompted, in the User Account Control dialog box, provide Backup Operator credentials, and then select OK.
  3. Select Local Backup.
  4. On the Action menu, select Backup once.
Jul 10, 2023

How do I restore my Active Directory user? ›

In order to restore AD objects, including users, you need to enable the Active Directory Recycle Bin feature. (Note that it cannot be disabled after that!) Navigate to “Start”, choose “Administrative Tools”, right-click on “Active Directory Module for Windows PowerShell”, and click “Run as Administrator”.

What is gen2 default password? ›

Old password Enter the current password (the default is ubnt).

What is the default password for hap ac2? ›

Once connected to the wireless network, open https://192.168.88.1 in your web browser to start configuration, since there is no password by default, you will be logged in automatically (or, for some models, check user and wireless passwords on the sticker).

What is the default username and password for cloud key gen2? ›

Note: You can click Configure to change the settings of the UniFi Cloud Key. The default login is ubnt/ubnt. After the UniFi Setup Wizard is finished, the UniFi Controller management interface will appear.

Is it possible to backup Active Directory? ›

You can back up Active Directory by performing a full server backup or system state backup. To do this, you can either use the Windows Server GUI or command-line tool.

How do I backup and restore my GPOs? ›

Right-click Group Policy Objects, and then select Manage Backups. In the Manage Backups dialog box, select Browse, and then locate the file that contains your backed-up GPOs. In the Backed up GPOs list, select the GPO that you want to restore, and then select Restore.

How to restore domain controller from backup? ›

In Windows Boot Manager, press the F8 key to access advanced boot options. Under Advanced Boot Options, select Directory Services Restore Mode, and then press the Enter key to start the DC in DSRM. Use the appropriate restore method for the tool that you used to create the system state backup.

What is the data backup and restore procedure? ›

Backup and restore refers to technologies and practices for making periodic copies of data and applications to a separate, secondary device and then using those copies to recover the data and applications—and the business operations on which they depend.

References

Top Articles
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 6274

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.