Enforcing security constraints around SSH public key types #4107
tomfitzhenry
started this conversation in
Show and tell
Replies: 1 comment
-
|
Hello and welcome, The straightforward way to deduplicate would be to apply the hosts: {
[string]: acceptedKeys: [Key=string]: _identities[Key]
"test-vm": acceptedKeys: {
"alice-laptop": _
"bob-server-key": _
}
}This may be a little bit weird for users. A list could be used instead and then processed to output the final struct, but it doesn't work well when composing multiple lists of keys that are set from different places because unifying of lists works by unifying each element 2 by 2 hosts: {
[string]: {
_acceptedKeys: [...string]
acceptedKeys: {
for key in _acceptedKeys {
(key): _identities[key]
}
}
}
[string]: _acceptedKeys: [ "sysadmin-security-key", ... ] // first element, need to know that there may be more (trailing ...)
"test-vm": _acceptedKeys: [ _, "alice-laptop", "bob-server-key" ] // need to know that there is a first element (leading _) and forbids more keys
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have a fleet of personal machines, some of which I consider to be important, and others that are throw-away. For the important machines, I try to enforce that only FIDO SSH keys can be used to SSH onto them.
In the past I've done this in Nixlang (via assertions to fail the build if a constraint is not satisfied), but I wanted to move to something a bit more distro-agnostic, to include my non-NixOS machines.
Here's what I've done in Cue:
The output is a JSON object, from hostname to the list of keys that the host should accept:
I then feed this JSON into NixOS, to ensure each host accepts the right set of keys. Likewise for other OSs.
This enforces two properties:
This is my first Cuelang, and I'm keen for any feedback.
In particular, is there a way to avoid awkward config like this:
Having "alice-laptop" twice feels like unnecessary code, and risk for weird bugs. A set (rather than a map or list) feels like a more natural data type. Maybe https://cuetorials.com/cueology/futurology/associative-lists/ would help me?
Beta Was this translation helpful? Give feedback.
All reactions