setSecret - Add secret to MATLAB vault - MATLAB (original) (raw)
Add secret to MATLAB vault
Since R2024a
Syntax
Description
setSecret([secretname](#mw%5Feb557c9c-5cf9-4956-8e48-9d52c1633900))
adds a secret with the specified name to your MATLAB® vault, which is accessible only from the exact combination of your operating system account and local machine.
Your vault and secrets, which do not leave your local machine, persist across MATLAB sessions. Each secret consists of a name, value, and optional metadata.
- Secret name – A unique case-sensitive text identifier for the secret. The secret name is stored unencrypted in your vault as a string scalar.
- Secret value – A text value associated with the secret. The Secret Prompt dialog box, where you enter the secret value, supports copy-paste functionality. The secret value is stored encrypted in your vault using industry standard AES-256 encryption. The secret value is returned as a string scalar.
- Secret metadata – A dictionary containing additional information associated with the secret. The optional secret metadata is stored unencrypted in your vault.
For increased security when you use MATLAB Online™, enable two-step verification for your MathWorks® Account.
setSecret([secretname](#mw%5Feb557c9c-5cf9-4956-8e48-9d52c1633900),Overwrite=[tf](#mw%5Fecceac04-026e-4759-9c65-826f0d09d807))
specifies whether to overwrite an existing secret value in the vault.
Examples
Create a secret by initiating the Secret Prompt dialog box with the name of your secret.
setSecret("SFTPpassword")
Use the dialog box to set your secret value and add the secret to your MATLAB vault. Toggle the eye icon in the text box to hide or show the characters in your value.
View all the secret names and metadata sizes in your vault.listSecrets
does not show secret values or the details of secret metadata.
SecretName SecretMetadata
______________ _______________________________________________
"SFTPpassword" {[dictionary (string ⟼ cell) with no entries]}
Create a secret to store your SFTP server password by initiating the Secret Prompt dialog box with the name of your secret.
setSecret("SFTPpassword")
Use the dialog box to set your secret value and add the secret to your MATLAB vault. Toggle the eye icon in the text box to hide or show the characters in your value.
To provide the SFTP server password, use the secret from your vault containing the password value.
s = sftp("sftp.example.net","adam",Password=getSecret("SFTPpassword"));
View all the secret names and metadata sizes in your vault.
SecretName SecretMetadata
______________ _______________________________________________
"SFTPpassword" {[dictionary (string ⟼ cell) with no entries]}
Initiate the Secret Prompt dialog box with the name of the secret whose value you want to overwrite. You can use tab completion to select an existing secret.
setSecret("SFTPpassword",Overwrite=true)
Set your new secret value using the dialog box.
View your updated vault. Note that there is no change to the secret name or metadata.
SecretName SecretMetadata
______________ _______________________________________________
"SFTPpassword" {[dictionary (string ⟼ cell) with no entries]}
Input Arguments
Unique case-sensitive text identifier for the secret, specified as a string scalar or character vector. You can use a secret to hold sensitive information, such as passwords, certificates, credentials, OAuth tokens, and other configuration data for:
- SFTP and FTP servers
- Password-protected files, such as PDFs
- Password-protected archives, such as zip files
- Cloud providers, such as Amazon S3™ and Windows Azure® Blob Storage
- API keys, SSH keys, and encryption keys
- Databases and applications
Overwrite the value of an existing secret with the same name, specified as a numeric or logical 0
(false
) or 1
(true
). This argument does not affect the metadata of the existing secret. If Overwrite
is false
,setSecret
produces an error if you attempt to overwrite the value of an existing secret. If Overwrite
is true
,setSecret
overwrites the value of an existing secret.
Version History
Introduced in R2024a
The secretname
argument now supports the forward slash character (/
).