# How to Securely Initialize a Nitrokey HSM 2 Remotely

**URL:** <https://support.nitrokey.com/t/how-to-securely-initialize-a-nitrokey-hsm-2-remotely/5913>\
**Category:** HSM\
**Created:** [February 1, 2024, 8:33am UTC](https://support.nitrokey.com/t/how-to-securely-initialize-a-nitrokey-hsm-2-remotely/5913 "2024-02-01T08:33:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bentruon](https://support.nitrokey.com/letter_avatar_proxy/v4/letter/b/c6cbf5/32.png) [@bentruon](https://support.nitrokey.com/u/bentruon)\
**Post date:** [February 1, 2024, 8:33am UTC](https://support.nitrokey.com/t/how-to-securely-initialize-a-nitrokey-hsm-2-remotely/5913/1 "2024-02-01T08:33:36Z")

</div>

How can I initialize a Nitrokey HSM 2 remotely if the host machine that the HSM is connected to is untrusted?

Use-case:  
I am the admin at location A. The Nitrokey HSM 2 is plugged into an untrusted host machine at location B. I would like to remotely initialize the Nitrokey HSM 2 with the so-pin, user pin, several key-pairs, and some certificates. Users at location B would then receive the user pin to use the HSM to sign device certificates, but I need to prevent them from exporting any of the objects to another HSM to ensure there is only one HSM with proper signing capabilities.

To do this, I will need a secure connection between myself and the Nitrokey HSM 2 to prevent any listener/MITM from seeing and modifying the initialization input.

How can this best be achieved?

---

<div class="post-metadata">

**Author:** ![sc-hsm](https://support.nitrokey.com/user_avatar/support.nitrokey.com/sc-hsm/32/304_2.png) [@sc-hsm](https://support.nitrokey.com/u/sc-hsm)\
**Post date:** [February 2, 2024, 8:25am UTC](https://support.nitrokey.com/t/how-to-securely-initialize-a-nitrokey-hsm-2-remotely/5913/2 "2024-02-02T08:25:59Z")

</div>

The SmartCard-HSM supports remote administration and that is actually a key feature of the [PKI-as-a-Service Portal](https://www.smartcard-hsm.com/2018/02/13/pki-as-a-service.html).

A remote secure channel can be established using the Device Authentication Key and the associated Device Certificate. Both are generated during production and are present on a SmartCard-HSM even before the device is initialized by the user. The secure channel protocol is based on TR-03110 and is the same mechanism used to protect APDU exchange on electronic passports and eID cards.

The secure channel allows a remote system to access the HSM, ensuring confidentiality and integrity of the APDU exchange. On top of the APDU exchange we use the RAM-Over-Http Protocol, which allows a webservice to access the remote device. RAM-Over-Http is supported in the [OpenSCDP Scriptingserver](https://www.openscdp.org/scriptingserver/index.html), which is the foundation for the PKI-as-a-Service portal.

To get this implemented, you could run your own instance of the PKI-as-a-Service software or write your own scripts using the ScriptingServer. The ScriptingServer comes with some examples that show how RAM-Over-Http works.

When you run your own instance of the PKI-as-a-Service software, you also have the option to write your own plug-in to support service request code that caters your specific needs.

Of course we provide professional services, but the software itself is available as Open Source in the [CDN](https://www.smartcard-hsm.com/cdn.html).
