tpm attest
Enterprise
Appropriate Vault Enterprise license required
Attest the local TPM to Vault and save a TPM-bound client certificate.
$ vault tpm attest [flags]
$ vault tpm attest [-help | -h]
Description
vault tpm attest runs a hardware-attested, two-phase enrollment protocol
(gentpmcert) with Vault using the local TPM, and gets a client TLS certificate
from the TPM auth method. The TPM must already be enrolled in the namespace of
the auth method mount. The private key stays in the TPM. The command writes only
key references and the certificate to the state directory. It creates the
directory, and any missing parent directories, if it does not exist. Refer to
Attestation state directory
for the files it writes.
To authenticate with the certificate, run
vault login -method=tpm with the same
-tpm-state-dir and the role_name of the role you attested against.
Command arguments
None.
Command options
None.
Command flags
-role-name (string : "")
Name of the TPM auth method role to attest against. Required for attest. For
reattest, the flag is optional if the existing client.crt encodes the role
name as a subject alternative name (SAN). In that case, the command uses that
role.
Example: -role-name my-role
-cert-subject-C (string : "")
Country (C) of the certificate subject, as a two-letter ISO 3166 country code.
Example: -cert-subject-C US
-cert-subject-CN (string : "<hostname>")
Common name (CN) of the certificate subject. Defaults to the hostname of the system.
Example: -cert-subject-CN server-01.example.com
-cert-subject-L (string : "")
Locality (L) of the certificate subject.
Example: -cert-subject-L "San Francisco"
-cert-subject-O (string : "")
Organization (O) of the certificate subject.
Example: -cert-subject-O "Example Corp"
-cert-subject-OU (string : "")
Organizational unit (OU) of the certificate subject.
Example: -cert-subject-OU Platform
-cert-subject-ST (string : "")
State or province (ST) of the certificate subject.
Example: -cert-subject-ST California
-mount-path (string : "auth/tpm")
Path where the TPM auth method is mounted.
Example: -mount-path auth/my-tpm
-tpm-device-path (string : "")
Path to the TPM device or to a Unix socket, such as /dev/tpmrm0 or
/dev/tpm0. Vault auto-detects the device when you omit this flag.
Example: -tpm-device-path /dev/tpmrm0
-tpm-state-dir (string : ".")
Directory that holds the TPM attestation state, which is the wrapped key blobs
and the certificates. attest creates the directory, and any missing parent
directories, if it does not exist. reattest, inspect and cleanup read an
existing directory.
Example: -tpm-state-dir /private
Standard flags
[-address | VAULT_ADDR] (string : 'https://127.0.0.1:8200')
Address of the Vault server.
Examples:
- CLI flag:
-address "https://mydomain/vault:8200" - Environment variable:
export VAULT_ADDR="https://mydomain/vault:8200"
[-agent-address | VAULT_AGENT_ADDR] (string : "")
Address of the Vault Agent, if used.
Examples:
- CLI flag:
-agent-address "https://mydomain/vault-agent:8200" - Environment variable:
export VAULT_AGENT_ADDR="https://mydomain/vault-agent:8200"
[-ca-cert | VAULT_CACERT] (string : "")
Path to a PEM-encoded CA certificate file on the local disk. Used to verify SSL
certificates for the server. Takes precedence over -ca_path.
Examples:
- CLI flag:
-ca-cert "/path/to/certs/mycert.pem" - Environment variable:
export VAULT_CACERT="/path/to/certs/mycert.pem"
[-ca-path | VAULT_CAPATH] (string : "")
Path to a directory with PEM-encoded CA certificate files on the local disk. Used to verify SSL certificates for the server.
Examples:
- CLI flag:
-ca-path "/path/to/certs/dir" - Environment variable:
export VAULT_CAPATH="/path/to/certs/dir"
[-client-cert | VAULT_CLIENT_CERT] (string : "")
Path to a PEM-encoded CA certificate file on the local disk. Used for TLS
communication with the server. The specified certificate must match to the
private key specified with -client-key.
Examples:
- CLI flag:
-client-cert "/path/to/certs/mycert.pem" - Environment variable:
export VAULT_CLIENT_CERT="/path/to/certs/mycert.pem"
[-client-key | VAULT_CLIENT_KEY] (string : "")
Path to a PEM-encoded private key that matches the client certificate set with
-client-cert.
Examples:
- CLI flag:
-client-key "/path/to/keys/myprivatekey.pem" - Environment variable:
export VAULT_CLIENT_KEY="/path/to/keys/myprivatekey.pem"
[-disable-redirects | VAULT_DISABLE_REDIRECTS] (bool : false)
Disable the default CLI redirect behavior so the CLI honors the first redirect response from the underlying API instead of following the full HTTP redirect chain.
Examples:
- CLI flag:
-disable-redirects - Environment variable:
export VAULT_DISABLE_REDIRECTS=1
-header (string : "")
Optional HTTP header in the form "<key>=<value>" for the CLI request. Repeat
the -header flag as needed with one string per flag. User-defined headers
cannot start with X-Vault-
Example: -header "Cache-Control=max-age=0"
[-mfa | VAULT_MFA] (string : "")
A multi-factor authentication (MFA) credential, in the format
mfa_method_id:passcode, that the CLI should use to authenticate to
Vault. The CLI adds MFA credentials to the X-Vault-MFA header when calling the
underlying API endpoint.
Examples:
- CLI flag:
-mfa "d16fd3c2-50de-0b9b-eed3-0301dadeca10:695452" - Environment variable:
export VAULT_MFA="d16fd3c2-50de-0b9b-eed3-0301dadeca10:695452"
[-namespace | -ns | VAULT_NAMESPACE] (string : <unset>)
Root namespace for the CLI command. Setting a default namespace allow relative mount paths.
Examples:
- CLI flag:
-namespace "admin" - Environment variable:
export VAULT_NAMESPACE="admin"
-non-interactive (bool : false)
Prevent the CLI from asking users for input through the terminal.
Example: -non-interactive
-output-curl-string (bool : false)
Print the API call(s) required to execute the CLI command as cURL strings
then exit without running the command.
Example: -output-curl-string
-output-policy (bool : false)
Print the Vault policy required to execute the CLI command as HCL then exit without running the command.
Example: -output-policy
-policy-override (bool : false)
Overrides any Sentinel policy where enforcement_level is "soft-mandatory".
Example: -policy-override
[-tls-server-name | VAULT_TLS_SERVER_NAME] (string : "")
Name of the SNI host for TLS handshake resolution for TLS connections to Vault.
Examples:
- CLI flag:
-tls-server-name "hostname.domain" - Environment variable:
export VAULT_TLS_SERVER_NAME="hostname.domain"
[-tls-skip-verify | VAULT_SKIP_VERIFY] (bool : false)
Disable verification for all TLS certificates. Use with caution. Disabling TLS certificate verification decreases the security of data transmissions to and from the Vault server.
Examples:
- CLI flag:
-tls-skip-verify - Environment variable:
export VAULT_SKIP_VERIFY=1
-unlock-key (string : <unset>)
Plaintext key that unlocks the underlying API endpoint for a given namespace.
Example: -unlock-key "7oXtdlmvRQ"
[-wrap-ttl | VAULT_WRAP_TTL] (string : "")
Default time-to-live in <number>[s|m|h|d] format for the Cubbyhole token used
to wrap CLI responses. You must use vault unwrap to view response data before
the duration expires. Leave wrap_ttl unset to leave CLI responses unwrapped.
Examples:
- CLI flag:
-wrap-ttl "5m" - Environment variable:
export VAULT_WRAP_TTL="5m"
Examples
Attest the local TPM against the my-role role and save the files to /private:
$ vault tpm attest -role-name=my-role -tpm-state-dir=/private
Attestation successful. Certificate valid until: Sat, 16 Jan 2027 17:00:00 UTC
Attest the local TPM with a custom certificate subject:
$ vault tpm attest -role-name=my-role -tpm-state-dir=/private \
-cert-subject-CN=server-01.example.com \
-cert-subject-O="Example Corp"
Authenticate with the issued certificate:
$ vault login -method=tpm -tpm-state-dir=/private role_name=my-role