1--- 2layout: "docs" 3page_title: "Seal/Unseal" 4sidebar_title: "Seal/Unseal" 5sidebar_current: "docs-concepts-seal" 6description: |- 7 A Vault must be unsealed before it can access its data. Likewise, it can be sealed to lock it down. 8--- 9 10# Seal/Unseal 11 12When a Vault server is started, it starts in a _sealed_ state. In this 13state, Vault is configured to know where and how to access the physical 14storage, but doesn't know how to decrypt any of it. 15 16_Unsealing_ is the process of constructing the master key necessary to 17read the decryption key to decrypt the data, allowing access to the Vault. 18 19Prior to unsealing, almost no operations are possible with Vault. For 20example authentication, managing the mount tables, etc. are all not possible. 21The only possible operations are to unseal the Vault and check the status 22of the unseal. 23 24## Why? 25 26The data stored by Vault is stored encrypted. Vault needs the 27_encryption key_ in order to decrypt the data. The encryption key is 28also stored with the data, but encrypted with another encryption key 29known as the _master key_. The master key isn't stored anywhere. 30 31Therefore, to decrypt the data, Vault must decrypt the encryption key 32which requires the master key. Unsealing is the process of reconstructing 33this master key. 34 35Instead of distributing this master key as a single key to an operator, 36Vault uses an algorithm known as 37[Shamir's Secret Sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) 38to split the key into shards. A certain threshold of shards is required to 39reconstruct the master key. 40 41This is the _unseal_ process: the shards are added one at a time (in any 42order) until enough shards are present to reconstruct the key and 43decrypt the data. 44 45## Unsealing 46 47The unseal process is done by running `vault operator unseal` or via the API. 48This process is stateful: each key can be entered via multiple mechanisms 49on multiple computers and it will work. This allows each shard of the master 50key to be on a distinct machine for better security. 51 52Once a Vault is unsealed, it remains unsealed until one of two things happens: 53 54 1. It is resealed via the API (see below). 55 56 2. The server is restarted. 57 58-> **Note:** Unsealing makes the process of automating a Vault install 59difficult. Automated tools can easily install, configure, and start Vault, 60but unsealing it is a very manual process. We have plans in the future to 61make it easier. For the time being, the best method is to manually unseal 62multiple Vault servers in [HA mode](/docs/concepts/ha.html). Use a tool such 63as Consul to make sure you only query Vault servers that are unsealed. 64 65## Sealing 66 67There is also an API to seal the Vault. This will throw away the master 68key and require another unseal process to restore it. Sealing only requires 69a single operator with root privileges. 70 71This way, if there is a detected intrusion, the Vault data can be locked 72quickly to try to minimize damages. It can't be accessed again without 73access to the master key shards. 74 75## Auto Unseal 76 77Auto Unseal was developed to aid in reducing the operational complexity of 78keeping the master key secure. This feature delegates the responsibility of 79securing the master key from users to a trusted device or service. Instead of 80only constructing the key in memory, the master key is encrypted with one of 81these services or devices and then stored in the storage backend allowing Vault 82to decrypt the master key at startup and unseal automatically. 83 84When using Auto Unseal there are certain operations in Vault that still 85require a quorum of users to perform an operation such as generating a root token. 86During the initialization process, a set of Shamir keys are generated that are called 87Recovery Keys and are used for these operations. 88 89For a list of examples and supported providers, please see the 90[seal documentation](/docs/configuration/seal/index.html). 91 92## Seal Migration 93 94The seal can be migrated from Shamir keys to Auto Unseal and vice versa. 95 96 ~> **NOTE**: This is not currently supported when using Vault Enterprise Replication. 97 While the primary can be migrated without issue, the secondaries, depending on 98 which type of seal is being migrated from/to, may not work correctly. We plan 99 to support this officially in a future release. 100 101To migrate from Shamir keys to Auto Unseal, take your server cluster offline and update 102the [seal configuration](/docs/configuration/seal/index.html) with the appropriate seal 103configuration. Bring your server back up and leave the rest of the nodes offline if 104using multi-server mode, then run the unseal process with the `-migrate` flag and bring 105the rest of the cluster online. 106 107All unseal commands must specify the `-migrate` flag. Once the required threshold of 108unseal keys are entered, unseal keys will be migrated to recovery keys. 109 110``` 111$ vault operator unseal -migrate 112``` 113 114To migrate from Auto Unseal to Shamir keys, take your server cluster offline and update 115the [seal configuration](/docs/configuration/seal/index.html) and add `disabled = "true"` 116to the seal block. This allows the migration to use this information to decrypt the key 117but will not unseal Vault. When you bring your server back up, run the unseal process 118with the `-migrate` flag and use the Recovery Keys to perform the migration. All unseal 119commands must specify the `-migrate` flag. Once the required threshold of recovery keys 120are entered, the recovery keys will be migrated to be used as unseal keys. 121 122## Recovery Key Rekeying 123 124During Auto Seal initialization process, a set of Shamir keys called Recovery Keys are 125generated which are used for operations that still require a quorum of users. 126 127Recovery Keys can be rekeyed to change the number of shares or thresholds. When using the 128Vault CLI, this is performed by using the `-target=recovery` flag to `vault operator rekey`. 129