Secrets and SSH Keys
SSH Keys/Secrets are used to store sensitive data used in Commands and Files and private SSH keys.
Note
A single entity is used for both types to employ a generic approach to sensitive data management.
Access Rules
| Group | Action | Condition |
|---|---|---|
| User | - | No access |
| Manager | R | Any type: user is added in "Users" or "Managers" |
| Manager | R | Type is "SSH Key": user is added in "Users" or "Managers" in related Server |
| Manager | R | Type is "Secret" |
| Manager | CRU | Any type: user is added in "Managers" |
| Manager | CRU | Type is "SSH Key": user is added in "Managers" in related Server |
| Manager | CRUD | Any type: user is added in "Managers" and the record is created by the user |
| Manager | CRUD | Type is "SSH Key": user is added in "Managers" in related Server and the record is created by the user |
| Root | CRUD | Any record |
Info
CRUD stands for Create, Read, Update, Delete.
SSH Keys/Secrets are located under the Cetmix Tower > Settings > Keys and Secrets menu.
SSH Key
Used to store SSH private keys. They are selectable in Server settings.
Fields
| Field | Description |
|---|---|
| Name | Readable name |
| Reference | Used for Odoo automation and YAML export/import. Leave blank to generate it automatically. |
| Reference Code | Complete reference code for inline usage in Commands and Files. |
| Key Type | Is "SSH Key" for this type of record. |
| Public Key | Public part of a key generated in Tower, in the OpenSSH format. Read-only. Visible to Managers. Use the copy button to copy it to the host, e.g. into ~/.ssh/authorized_keys. Empty when the private key was entered manually. |
| Note | Put your notes here. |
Notebook Tabs (SSH Key)
| Tab | Description |
|---|---|
| Key Value | Key value. Please check the note below for more information. |
| Used For | List of Servers where this SSH key is used |
| Access | Access Roles for this record for specific users. |
Warning
Key Value is a write-only field. Please ensure that you have saved your secret before saving it. Once saved, it becomes inaccessible from the user interface.
Generate an SSH Key
Tower can create the key pair itself, so you do not need to run ssh-keygen. Save the SSH Key record first.
- Click Generate. If the record already has a private key, the button is Regenerate. Tower asks you to confirm first.
- Select the Key Type and click Generate.
| Key Type | Algorithm |
|---|---|
| Ed25519 | Ed25519. Default. |
| ECDSA (nistp256) | ECDSA, curve nistp256 (256 bit) |
| RSA (4096 bit) | RSA, 4096 bit |
The private key is stored in Key Value in the OpenSSH format without a passphrase. The Public Key field shows the public part.
Warning
Regenerate replaces the existing private key. The old private key cannot be recovered. Hosts that trust the old public key will no longer accept this key.
Note
If you change Key Value manually, Public Key is cleared.
Generate an SSH Key in a Flight Plan
A Flight Plan can generate a key while it configures a server. For example, it can move a server from password to key authentication. Generate the key in a Python Code Command and pass the public key to later commands through custom_values:
key = env["cx.tower.key"].create(
{"name": "SSH key " + server.name, "key_type": "k"}
)
custom_values["_ssh_key_id"] = key.id
custom_values["_ssh_public_key"] = key._generate_ssh_key(key_type="ed25519")
result = {"exit_code": 0, "message": custom_values["_ssh_public_key"]}
key_type is ed25519 (default), ecdsa or rsa. Then add the public key on the host with SSH Commands, one per Flight Plan line:
mkdir -p -m 700 ~/.ssh
echo "{{ _ssh_public_key }}" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Finally, switch the server to the new key with another Python Code Command:
server.write({"ssh_key_id": custom_values["_ssh_key_id"], "ssh_auth_mode": "k"})
result = {"exit_code": 0, "message": "Server uses the new SSH key"}
The user who runs the Flight Plan needs write access to the server.
Warning
Create a new key for each run. Do not regenerate the key the server already uses: the same key can be used by other servers, and they would lose access until their hosts get the new public key.
Tip
Switch the server to the new key only after the public key is added on the host. The server password stays stored, so you can switch SSH Auth Mode back to password if the new key does not work.
Secret
Used to store sensitive information that can be used inline in commands, e.g., a token or a password. Secrets cannot be previewed in command preview and are replaced with a placeholder in Command logs.
| Field | Description |
|---|---|
| Name | Readable name |
| Reference | Used for Odoo automation and YAML export/import. Leave blank to generate it automatically. |
| Reference Code | Complete reference code for inline usage in Commands and Files. |
| Key Type | Is "Secret" for this type of record. |
| Partner | Secret type only. If selected, this secret is used only for the selected partner Servers. |
| Server | Secret type only. If selected, this secret is used only for the selected Server. |
| Note | Put your notes here. |
Notebook Tabs (Secret)
| Tab | Description |
|---|---|
| Secret Value | List of secret values. Values marked as "Global" are used if no partner or server is selected. |
| Access | Access Roles for this record for specific users. |
Warning
Secret Value is a write-only field. Please ensure that you have saved your secret before saving it. Once saved, it becomes inaccessible from the user interface.
Secret Value Priority
When a secret is parsed, its value is searched in the following order:
- Server and partner specific. Both "Server" and "Partner" fields match the current server and partner.
- Server specific. "Server" field matches the current server, "Partner" field is not set.
- Partner specific. "Partner" field matches the current partner, "Server" field is not set.
- Global. Both "Server" and "Partner" fields are not set.
Secrets are inserted inline in code using the following pattern: #!cxtower.secret.reference!#. It consists of three dot-separated parts and is terminated with a mandatory !# suffix:
#!cxtoweris a special prefix that indicates that the following text is a Cetmix Tower secret.secretis used to declare its type (secret).referenceis the Reference field value.
Example
Suppose we have a secret with my_secret_dir reference and value suchMuchFolder. In this case, the following command:
mkdir /home/#!cxtower.secret.my_secret_dir!#
will be executed as:
mkdir /home/suchMuchFolder
YAML Format Specification
cetmix_tower_model: key
reference: such_much_secret
key_type: s # s for secret, k for ssh key
name: 'Such Much Secret'
Info
Secret values cannot be exported or imported using YAML. They must be saved manually in the UI.
Please refer to the General YAML Format Specification for more details.



