Storing passwords and keys in Lemano
A target file never holds a password or a key: it names where to find one. Keys are recommended over passwords: a key never leaves your machine, while a password is sent to the server, which could use it elsewhere if it were compromised. Use a password only for a server that takes nothing else.
Choosing a reference
| Reference | Where the value is | Use it when |
|---|---|---|
agent (credential only) | your SSH agent | you already load your keys into an agent; the default |
file:<path> | a file only you can read | the value already lives in a file (a key, a password file a tool writes) |
env:<NAME> | an environment variable | a scheduler or CI job hands the value to the command |
prompt (passwords only) | typed on the terminal, without echo | you run Lemano by hand and do not want the password stored anywhere |
secret://<name> | Lemano’s encrypted store | you want the value kept with your history, encrypted with the store’s key |
ansible://<host>?inventory=<source> (passwords only) | an Ansible inventory, asked at each use | the password is already in an inventory, perhaps vault-encrypted, and you want one place for it |
spec.connector.credential takes agent, file:, env: and
secret://; spec.connector.password and spec.connector.sudoPassword
take env:, file:, prompt, secret:// and ansible://.
Passwords from an Ansible inventory
An ansible:// reference is read by lemano-ansible, the Ansible
integration, which is installed in the same folder as lemano and
released with it. lemano itself knows nothing of Ansible: it hands the
reference to that program, which asks Ansible (see credential
helpers).
ansible://web-07?config=../ansible.cfg&inventory=../inventories/prod/hosts.yml
makes Lemano ask Ansible for the password of the inventory host web-07,
each time it is needed: ansible_password (or ansible_ssh_pass,
ansible_ssh_password) for the login, ansible_become_password (or
ansible_become_pass, ansible_sudo_pass) for sudo; when several are
set, the one Ansible itself uses. Ansible decrypts or renders the value
with the configuration file named by config (passed as ANSIBLE_CONFIG,
and Ansible runs in its folder, so the relative paths in it work from any
folder), your vault settings and environment, without connecting to any
host, and Lemano keeps it in memory only while it is used. The import
writes these references for you: see Importing an Ansible
inventory.
A relative config or inventory is relative to the target file’s
folder, as a file: path is; give inventory once per source, or not at
all to use Ansible’s default, and config not at all when no
configuration file is in effect. Ansible must be installed on the machine
that runs Lemano. Nothing of the value is stored by Lemano or by Ansible:
the security model says how
Ansible is kept from recording it.
The secret store
lemano secret set sudo/web-07 # asks twice, without echo
lemano secret set ssh/deploy --from-stdin < ~/.ssh/deploy_key
lemano secret list
lemano secret delete sudo/web-07spec:
connector:
type: ssh
host: web-07.example.com
credential: secret://ssh/deploy
sudoPassword: secret://sudo/web-07- A value is read from the terminal or from standard input, never from an argument or an environment variable on the command line, where other users and the shell history could see it. One final line ending from standard input is dropped.
- Setting an existing name replaces its value, and says so.
- No command prints a value back;
secret listshows names and times only. - A name is one or more parts separated by
/, each of letters, digits,.,-,_and@, at most 256 characters. Names are case-sensitive. - A private key with a passphrase cannot be stored this way: such keys are used through the SSH agent only, and Lemano never asks for a passphrase.
- A reference to a missing secret fails with the secret’s name.
How the values are protected is in the security model.