Target files
A target file declares the servers Lemano discovers: one YAML document per
target, several per file allowed. lemano discover -f PATH reads every
.yaml and .yml file under PATH, skipping documents of other groups.
The JSON Schema is schemas/target.json.
apiVersion: lemano.dev/v1alpha1
kind: Target
metadata:
name: web-07
labels:
env: prod
role: web
spec:
connector:
type: ssh
host: web-07.example.com
port: 22
user: lemano
credential: file:../keys/web-07
privilege: root
sshConfig: true
timeouts:
connect: 10s
command: 1m
pass: 10m
discovery:
interval: 1hmetadata
| Field | Meaning |
|---|---|
name | Unique across all the target files loaded: lowercase letters, digits, - and ., starting and ending with a letter or a digit, at most 253 characters. |
labels | Pairs to select targets with (lemano discover -l env=prod). A name is letters, digits, -, _ and ., starting and ending with a letter or a digit, at most 63 characters; a value is empty or follows the same rule, and values YAML could read as another type ("1.10") are quoted. os, os.version, family and arch are set by Lemano from what it discovers and cannot be declared. Names that start with ansible.lemano. are written by lemano ansible import and only the files it generates may declare them. |
spec.connector
| Field | Default | Meaning |
|---|---|---|
type | ssh, the only connector. | |
host | A host name, an IP address, or an alias of your ssh configuration. | |
port | 22 | The SSH port. |
user | lemano | The login: a dedicated, non-root account that escalates with sudo -n. |
credential | agent | A reference to the key, never the key: agent, file:<path> (relative to the target file’s folder), env:<NAME> or secret://<name> (a key stored with lemano secret set). It is offered before any key your ssh configuration names. |
password | A reference to the login password, never the password: env:<NAME>, file:<path> (only its owner may read it; relative to the target file’s folder), secret://<name>, ansible://<host>?config=<file>&inventory=<source> (asked of Ansible at each use, by the lemano-ansible program installed beside lemano; a relative config or source is relative to the target file’s folder). Any other <scheme>://... is asked of the program lemano-<scheme>: see credential helpers or prompt. Offered after the keys, only to a host whose key is pinned. Keys are recommended. | |
sudoPassword | A reference to the password sudo asks for: env:<NAME>, file:<path>, secret://<name>, ansible://<host>?config=<file>&inventory=<source> or prompt. Used only where sudo -n is refused, tried once. | |
privilege | root | root: the pass runs as root through sudo -n, and falls back to the login user when sudo is refused (what it cannot read then makes the pass partial). user: the target is run without sudo on purpose and what needs root is recorded as skipped. |
sshConfig | true | Read the settings this file leaves out from your ssh configuration, through ssh -G. false uses this file’s settings only. |
proxyJump | Jump hosts in OpenSSH’s syntax: [user@]host[:port], separated by commas, reached in order. Each one’s key is pinned. See proxyJump. | |
proxyCommand | A command run on your machine, through your shell, whose standard input and output carry the connection; %h, %n, %p, %r and %% are replaced. It cannot be combined with a proxyJump other than none. See proxyCommand. | |
hostKey | The host key or keys the target must present: an OpenSSH public key line or a SHA256: fingerprint, or a list of them (a host has one key per key type). See hostKey. | |
timeouts.connect | 10s | To connect and authenticate, for the target and for each jump host. |
timeouts.command | 1m | For one command. |
timeouts.pass | 10m | For a whole pass, jump hosts included. |
proxyJump
proxyJump is OpenSSH’s ProxyJump syntax: one or more hops, separated by
commas and visited in order, each [user@]host[:port]; an IPv6 address goes
in square brackets (ops@[2001:db8::1]:2200). ssh://[user@]host[:port] is
accepted for a hop too. The value none turns a jump host off, for a target
that a jump host from your ssh configuration would otherwise be applied to.
An error names the hop that is wrong. Each hop’s host key is pinned like the
target’s own, and a changed key is refused; lemano target rekey NAME --jump HOST:PORT re-pins one.
hostKey
hostKey says in advance which key the target must present, so the first
connection does not rely on trusting whatever answers. Each entry is an
OpenSSH public key line (ssh-ed25519 AAAA..., a trailing comment is
allowed) or a SHA-256 fingerprint as ssh-keygen -lf prints it
(SHA256:...); give a list when the host has several key types.
spec:
connector:
host: web-07.example.com
hostKey:
- SHA256:mKqU+0K8OhKmA8bBQi9Rz0Q5l7/g160hIP+rJYSTNj4
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8g- On the first connection only a key named here is accepted, before
anything is read, and it is pinned: the setting stands for accepting the
key, so
--accept-new-host-keyis not needed. Any other key is refused (exit code 4, reasonHostKeyUnexpected) with its fingerprint and the ones expected, and nothing is read or pinned, whatever flags are given. - When a key is already pinned for the host and the setting does not name
it, the connection is refused and says so, even though the host presents
the pinned key: the setting and the pin disagree. Fix the setting, or
replace the pin with
lemano target rekey. - The setting covers the target, not its jump hosts. A host certificate or a certificate authority is not accepted as a value.
proxyCommand
proxyCommand is the command OpenSSH’s ProxyCommand runs: its standard
input and output are the connection to the target, and %h, %n, %p, %r
and %% are replaced. It is one line without control characters.
A proxyCommand runs on the machine where lemano runs, with the rights of
the user who runs it, through that user’s shell. Reading a target file with
a proxyCommand is running its command, and a target imported from an
inventory that sets -o ProxyCommand=... carries that command. Read a target
file that you did not write, or that was generated from an inventory you did
not write, before you run lemano discover on it. Lemano never puts a command
line in an error message or a log, because a command can carry a secret; keep
passwords out of it all the same, and use a key or the agent.
Passwords
A password is never written in a target file: the loader refuses a value
that is not a reference, without repeating it. prompt asks on the
terminal, without echo, once per target and command; without a terminal
the command fails. The global flags --password-prompt and
--sudo-password-prompt do the same for every target whose file names
no password. lemano target show shows only that a password was used and
the kind of its reference. See Storing passwords and keys in
Lemano and Security
model.
Settings from your ssh configuration
With sshConfig on (the default) and an OpenSSH client on PATH, the
settings this file leaves out come from your ssh configuration when it sets
them: the host name behind an alias (HostName), Port, User, the
identity files, the agent socket, ProxyJump, ProxyCommand and a shorter
ConnectTimeout. A setting this file states always wins; a proxyCommand
here wins over any jump host or proxy command of the configuration. Host
keys are always checked against Lemano’s own known_hosts. The details,
and the global switch --ssh-config, are in
Using your SSH config.
spec.discovery
| Field | Default | Meaning |
|---|---|---|
interval | 1h | How often a pass is expected, from 1m to 8760h; see Scheduling. |
includePaths | Files or directories to read beyond the defaults (all of /etc, /usr/local/etc, the cron spool and each user’s authorized_keys); *, ? and [...] match within one path element, as in excludePaths (/home/*/.tmux.conf), and a name that starts with a dot is matched only by a pattern that starts with one. Files that hold credentials are never read, even when named: see Files never read. | |
excludePaths | Files or directories not to read; *, ? and [...] match within one path element. | |
contentExcludePaths | Files or directories read without storing their content: a change still shows, by a keyed hash. | |
acceptNotRead | Gaps this target accepts, as a list of reason and paths; see What a pass does not read. | |
contentLimit | 1Mi | The largest file whose content is stored, at most 50M. |
userFiles | The users’ own files to read; see Users’ own files. | |
addedFileLimit | 256Ki | The largest file added by includePaths or userFiles whose content is stored, at most 50M. A larger one keeps its metadata and a keyed hash, and is counted with the reason overLimit. |
addedFileCount | 1000 | The number of files includePaths and userFiles may add to a pass, from 1 to 20000. Past it, files are left out in path order and counted with the reason overLimit. Files of the default places are not counted. |
packageCheckInterval | 24h | How often the package manager’s full check of every package file runs, from 1h to 8760h; the other passes check only the package files whose metadata changed. See the File kind’s package files. |
What a pass does not read
A pass names every reason it did not read something. Each reason is kept
with the error (reason in -o json) and shown by discover, target show,
history and summary.
| Reason | Meaning | Partial |
|---|---|---|
unsafeFolder | The file is in a folder that users other than the one who would read it can change (a folder anyone can write to without the sticky bit, or one a group of users can change). Reading it could follow a link swapped in after the check. | yes |
permissionDenied | The account the pass ran as may not read it. On a target with privilege: user this is a skipped gap, never partial. | yes |
notRegular | A symbolic link or a special file, which are not read. | yes |
vanished | Listed, then gone when read: a race, not a gap. | no, listed only |
hostKernel | A kernel parameter of the host, outside the user namespace the pass runs in: even its root cannot read it. | no, listed only |
credentials | The file holds credentials, by its name or its content: see Files never read. The text output of discover and target show counts them in one line; -o json and history name each. | no, counted |
overLimit | A file the target adds is larger than addedFileLimit, or past addedFileCount. | no, listed only |
noSuchUser | A user userFiles names is not on the host: nothing of theirs is read. | no, listed only |
unreadable, contentChanged, invalidPath | The read began and failed or timed out; the content changed between the two reads of a pass; the path is not a valid name. | yes |
passTimeLimit | The pass ran out of its time limit (spec.timeouts.pass) before it read the kind or the file’s content. What was read is kept in a partial generation, and the next pass reads the rest. | yes, and never accepted |
stepFailed, stream, connection | A step failed or ran out of time; the record stream was cut or wrong; the connection failed. | yes, and never accepted |
acceptNotRead accepts the reasons unsafeFolder, permissionDenied and
notRegular, one entry per reason, for the paths you name (matched like
excludePaths; a folder covers what is below it):
spec:
discovery:
acceptNotRead:
- reason: unsafeFolder
paths:
- /etc/appAn accepted gap does not make the pass partial, so the pass exits 0 and
a generation is complete. It is never silent: the file stays listed with
its reason and accepted: true, target show counts it in its note, and history
and summary carry it (gapsNotRead in summary -o json). Lemano does
not see changes to a file it does not read. The same reason on a path the
entry does not cover still makes the pass partial. When a pass is partial
only for reasons that can be accepted, lemano discover ends with the
lines to add, grouped by reason and folder.
Users’ own files
A pass reads no file in users’ homes but their authorized_keys. A
target’s first pass names the ordinary users with a home whose files it
does not read, apart from the account the target logs in as. A user
userFiles names that the host does not have is reported on each pass
with the reason noSuchUser. userFiles reads the files of the users it names:
spec:
discovery:
userFiles:
users: [alice, deploy]
preset: true
paths: [.config/nvim/init.lua, ".config/tmux/*"]| Field | Default | Meaning |
|---|---|---|
users | The users, by name; required. There is no setting for every user: each is named. | |
preset | true | Read the preset’s files: .profile, .bashrc, .bash_profile, .bash_login, .bash_logout, .bash_aliases, .zshrc, .zprofile, .zshenv, .zlogin, .zlogout, .inputrc, .tmux.conf, .screenrc, .vimrc, .nanorc, .gitconfig, .config/git/config, .config/git/ignore, .ssh/config and .ssh/known_hosts. |
paths | More files, folders or patterns, relative to each user’s home; *, ? and [...] match within one path element. |
Each file is read as the user who can change its folder, under the same
folder rule as every file. Files that hold credentials are never read
(next section), and addedFileLimit and addedFileCount bound the rest.
The folders between the home and each file are recorded too, so that an
export makes them as they were. Only these files are in the scope of a
check: nothing else in a home is listed as forgotten.
Files never read
Some files hold credentials by their nature, and Lemano never reads them,
wherever they are and whatever the target names: their content is not
fetched, not stored and not hashed. Each keeps its path, owner, group, mode
and size, so a pass still sees it appear, disappear or change mode; its
record carries credentials: true, and the pass lists it with the reason
credentials. An export lists it to move or replace by hand.
- By name or place: SSH private keys (
id_rsa,id_ed25519and the other namesssh-keygengives,ssh_host_*_key), PuTTY keys (*.ppk), GnuPG private keys (.gnupg/private-keys-v1.d/,.gnupg/secring.gpg) and keyrings (.local/share/keyrings/), login files (.netrc,_netrc,.pgpass,.git-credentials,.Xauthority,.ICEauthority), cloud, container and forge clients’ logins (.aws/credentials,.s3cfg,.docker/config.json,.kube/config,.config/gh/hosts.yml), and command histories (*_history,.history,.zhistory,.lesshst,.viminfo). Case is ignored. - By content, for any other file: a private key (PEM, OpenSSH or OpenPGP
armour, or a client key given inline in a Kubernetes client
configuration), an npm registry login (
_authToken,_auth,_password), or a container registry login ("auth","identitytoken"). Such content is read once to be checked, and nothing of it is kept.
Limits
A file is at most 1 MiB and holds at most 1000 documents. Credentials are references only: a document that holds something shaped like private key material is refused, without the value being repeated.