> For the complete documentation index, see [llms.txt](https://docs.oceanenterprise.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.oceanenterprise.io/infrastructure/signer-server-installation-and-configuration/key-generation-and-management-in-openbao-secrets-vault/migrate-private-keys-from-metamask-to-openbao-vault.md).

# Migrate private keys from MetaMask to OpenBao Vault

Use this when an existing MetaMask account already holds funds, permissions, or on-chain identity that the deployment needs to keep.

> **Warning.** Exporting a private key from MetaMask removes every protection the extension provides. Perform this on a trusted machine, never over screen-share, never into a chat or ticket, and never into shell history (`export HISTFILE=/dev/null` or prefix commands with a space where your shell supports it).

## **Step 1 — Export the key from MetaMask**

1\. Open MetaMask and select the account to migrate.

2\. Open the account menu (⋮) → **Account details**.<br>

<figure><img src="https://1789397093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH0zpgrXbeZ7u6UuCV9Gz%2Fuploads%2FMctWsK4dcv308zK9nV6f%2Fimage.png?alt=media&amp;token=cff5a55a-c47e-4354-b182-a3ce5391e37f" alt="" width="375"><figcaption></figcaption></figure>

3\. Choose **Private keys** and click on the option "**Unlock to reveal**"

<figure><img src="https://1789397093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH0zpgrXbeZ7u6UuCV9Gz%2Fuploads%2FeueSahWMuIFSuaoShkbs%2Fimage.png?alt=media&amp;token=0aa5e9a1-a37c-4040-8aa7-b2bd0059eb38" alt="" width="371"><figcaption></figcaption></figure>

4\. Enter your MetaMask password and hold to reveal.

<figure><img src="https://1789397093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH0zpgrXbeZ7u6UuCV9Gz%2Fuploads%2FgeNGAwmU1tcawP1nA5lz%2Fimage.png?alt=media&amp;token=75825df9-b7b1-471c-8227-a56a932a4479" alt="" width="375"><figcaption></figcaption></figure>

5\. Copy the 64-character hex string. Record the account's **address** separately — you will verify against it in step 4.

<figure><img src="https://1789397093-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FH0zpgrXbeZ7u6UuCV9Gz%2Fuploads%2Fu3yV6lica8Q8kY3kjEYV%2Fimage.png?alt=media&amp;token=de9c1937-60a2-4669-b04e-f0232983a563" alt="" width="360"><figcaption></figcaption></figure>

MetaMask exports the key without a `0x` prefix. That is fine: `normalize_pk` adds it during import.

### **Step 2 — Add the key to the keys file**

```bash
cd <module>/docker-compose/openbao
​
# Note the leading space to keep this out of shell history (bash/zsh with HIST_IGNORE_SPACE)
 printf '0x%s\n' "<pasted-key-lowercased>" >> secrets/private_keys
​
chmod 600 secrets/private_keys
```

Alternatively, import from a throwaway file and let the deployment persist it:

```bash
docker compose cp /tmp/metamask_key.txt openbao:/vault/keys/tmp/metamask_key.txt
docker compose exec openbao /opt/openbao/scripts/manage-accounts.sh \
  import --private-keys-file /vault/keys/tmp/metamask_key.txt --persist
docker compose exec openbao rm -f /vault/keys/tmp/metamask_key.txt
shred -u /tmp/metamask_key.txt   # or: rm -P on BSD/macOS
```

With `--persist` (the default), the key is appended to the persistent keys file so it survives a container rebuild.

## **Step 3 — Import**&#x20;

If you appended to `secrets/private_keys`, run the standard import:

```bash
docker compose exec openbao /opt/openbao/scripts/manage-accounts.sh import
```

## **Step 4 — Verify the address matches MetaMask**

```bash
docker compose exec openbao /opt/openbao/scripts/manage-accounts.sh list --verify
```

The address on the new row must match the address you recorded in step 1, case-insensitively. If it does not, the key was mistyped or truncated — delete the wallet and repeat.

## **Step 5 — Decommission the browser copy**

Once the vault-held key is confirmed working through the Signer Server:

* remove or lock the account in MetaMask so the same key is not signing from two places;
* clear the clipboard and any editor buffer or scratch file that held the key;
* confirm the key never entered shell history: `grep -c '0x[0-9a-f]\{64\}' ~/.bash_history` should return `0`.

> **Direction of travel.** This migration is one-way by design. Once the key is in OpenBao, all signing should go through the Signer Server (`SIGNER_MODE=vault`), not through the browser extension.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.oceanenterprise.io/infrastructure/signer-server-installation-and-configuration/key-generation-and-management-in-openbao-secrets-vault/migrate-private-keys-from-metamask-to-openbao-vault.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
