Templated Secrets #3202
Replies: 6 comments 22 replies
-
Specifically for bitwarden, 'logging in' is determined by an environment variable, so maybe one option would be to populate that environment variable effectivly. But I'm not suggesting this based on expereince. If the above isn't feasable, one option I can suggest is separating the secret's based chezmoi configuration separate. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, chezmoi cannot know the difference without the authorization. Really, there are three options (I’m assuming bash/zsh here):
We would also welcome a PR contribution to add This is not necessary with 1Password 8 & 1Password CLI 2 on a system with biometric authentication enabled for CLI access. I do not see similar options for either Bitwarden desktop or CLI. |
Beta Was this translation helpful? Give feedback.
-
@halostatue I realize chezmoi can't compute the difference in templates which contain references to a password manager without authorization, but I don't think it should be trying to compute the difference on each invocation of From a security perspective, it'd be better to compute differences in these kinds of templates only when the user specifically requests to do so, or at least have the option of turning this behavior on and off. The problem is with unauthorized access to the machine. When unauthorized access to the machine occurs, without using chezmoi, at most the private key files are exposed. With chezmoi, not only are the private key files exposed, but an open door into the entire password manager and all of its passwords. I would much rather give up a private key file since these are typically encrypted with a password anyway (with often the password stored in the password manager) than access to my entire password manager. I think @Lockszmith-GH 's approach to layering works well for this, but as a chezmoi newbie setting up that kind of structure is daunting. I'm willing to give it a shot, but it's a bit like bringing a tank to a knife fight since I'm not an organization, just an individual who doesn't want to reconcile differences in secrets every time I use chezmoi. If there was a built-in way to manage contexts/namespaces, and selectively turn those on and off, it'd simplify the process. I don't think I'm alone in this problem. I realize this is asking a lot though! |
Beta Was this translation helpful? Give feedback.
-
chezmoi must compute that there is a difference between all files in its source state and the target state for most of the stated commands to work. That is, computing that difference is the entire point of what chezmoi does.
Your threat model is wrong. If someone has unauthorized access to your machine, then they can use If you’re that worried about unauthorized access to your machine, you probably shouldn't have a password manager on your system at all, and should be typing your passwords &c. manually by reading them off your phone. If you’re doing a lot with $ rbw unlock
# perform unlock
$ chezmoi status
…
$ chezmoi merge foo
…
$ chezmoi apply
$ rbw lock The first step isn’t necessary because both The 1Password CLI has better handling of its session tokens (30 minute expiry) and can also use 1Password 8 as an agent daemon (10 minute authorization expiry) where the lock status is shared between the desktop app and the 1Password CLI.
There is no concept of 'context' or 'namespace' in chezmoi, and based on previous discussions, it is highly unlikely that they will be introduced for any reason. What's important to realize is that once you have a single The only way to namespace is through the more complex mechanisms that @Lockszmith-GH has documented by using multiple state files and paths. I'm not sure whether we would want to adapt this into some sort of "advanced use cases" section of the documentation, but it would never be a mainstream recommendation for running chezmoi. |
Beta Was this translation helpful? Give feedback.
-
That's exactly what I want it to do, except I don't want it to do this for secrets every time I run it since that requires unlocking something in some kind of a password manager, be it BitWarden, 1Password, etc.
If
I guess this is really the only way it can be done with the present state of chezmoi. I'll try to implement this. |
Beta Was this translation helpful? Give feedback.
-
Another way to achieve the goal of excluding files with secrets from chezmoi except when explicitly wanted is to use a In your
Then, if you run chezmoi with the environment variable You'll of course need to maintain the list of files containing secrets yourself. |
Beta Was this translation helpful? Give feedback.
-
Hello, I recently started using chezmoi and I am thoroughly impressed! I added most of my dot files and put my
.ssh
directory on hold until now. I discovered a few different blog articles that suggest using a password manager to store the SSH private keys and using chezmoi templates to populate the actual secrets.I tried this using BitWarden, but soon after I got it to work almost every chezmoi command wanted me to login to BitWarden so that the templates could be reconciled (
status
,verify
, etc.).I came across issue #2888 and it seems like a similar pain point I'm having. I don't think it's a good idea to have an exposed session key in an environment variable all the time, particularly when it's rarely needed. I understand that there's no way for chezmoi to reconcile the source and target without using the password, but most of the time those files rarely change.
I tried doing the suggested workaround of adding the key to the ignore list if it already exists, but when you have several keys to add it seems a bit tedious. The key name has to be repeated both in the templating logic as well as in the template output itself (not very DRY).
Another thought I had is just to simply check the keys into source control as long as the private keys are encrypted with a password, but I realize that's not good practice since it opens the key up to brute-force attacks should the key be obtained via git. This is similar to using something like Mozilla SOPS or encrypting the data before it's checked in.
It'd be nice to slice off specific files from always being reconciled, in some sort of context/namespace. Perhaps a property within the template could be used to identify which context the template belongs to and then have some sort of CLI switch to turn on contexts to reconcile.
Is there a better workaround? I thought maybe I could define a list of files within the ignore template and have the template loop through all the files with similar logic as the example mentioned in #2888 but I'm not sure if that's possible.
Beta Was this translation helpful? Give feedback.
All reactions