Closed joshoram80 closed 1 year ago
I don’t understand your system here or what you’re trying to accomplish.
If you have sudo
access to be able to change the ownership and permissions of unencrypted secrets, and you’re not on a multi-user machine, your user is effectively the same as root
and you‘re creating pain for maintenance with no measurable security benefit. If you’re on a multi-user machine, then you are giving away the secrets to whomever does have root
access with essentially no fences at all.
As far as what you’re doing, you’re pushing the boundaries of what chezmoi is intended to do, and as you have seen, scripts don’t run before/after diff
, merge-all
, etc.
In order to try to help you better with this, can you answer the following questions?
The docker secrets are things like passwords and API keys. They are being stored in my dotfiles repository mainly as a backup along with the rest of my home server configuration.
The permissions on the files are more of a 'just in case' scenario. I guess technically they don't need to be private and owned by root on the server.
On Wed, 22 Mar 2023, 1:40 am Austin Ziegler, @.***> wrote:
I don’t understand your system here or what you’re trying to accomplish.
If you have sudo access to be able to change the ownership and permissions of unencrypted secrets, and you’re not on a multi-user machine, your user is effectively the same as root and you‘re creating pain for maintenance with no measurable security benefit. If you’re on a multi-user machine, then you are giving away the secrets to whomever does have root access with essentially no fences at all.
As far as what you’re doing, you’re pushing the boundaries of what chezmoi is intended to do, and as you have seen, scripts don’t run before/after diff, merge-all, etc.
In order to try to help you better with this, can you answer the following questions?
- What sort of docker secrets are you talking about?
- What is your threat model? That is, what attack mode are you trying to protect your docker secrets from?
— Reply to this email directly, view it on GitHub https://github.com/twpayne/chezmoi/issues/2879#issuecomment-1477961223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP7FG65HT7NPS2ARFEHDQDW5G4VTANCNFSM6AAAAAAWB6IPAY . You are receiving this because you authored the thread.Message ID: @.***>
The docker secrets are things like passwords and API keys. They are being stored in my dotfiles repository mainly as a backup along with the rest of my home server configuration.
That's sensible enough, although I would probably use 1Password secret injection or something similar for running Docker and/or setting up the configuration files.
The permissions on the files are more of a 'just in case' scenario. I guess technically they don't need to be private and owned by root on the server.
So this is on a home server where you log in as user X to manage the server, and your running Docker images are configured to look for various API keys and such in ~x/docker-secrets/…
, but right now you do chown root:root -R ~x/docker-secrets && chmod 0700 ~x/docker-secrets
after writing them.
Especially if you’re not logged onto the server all the time, I would absolutely skip the chown
dance (chezmoi can already handle most of the chmod as long as the user is yourself by naming it private_docker-secrets
in the source state). If you are logged into the server all the time. If you’re worried about applications that you are running from doing this, I would set up a different chezmoi dotfiles repo and either make it deployed by root
(this is allowed) or by a different, non-privileged user (this would be preferred).
I actually do something similar to 1Password Injection for pretty much any secret that is not supported by a Docker container. I use 'pass' and the built-in chezmoi integration to inject passwords and keys into the docker .env file using a chezmoi template.
I already have my .password-store folder under version control as it is encrypted by default.
On Wed, 22 Mar 2023, 10:51 am Austin Ziegler, @.***> wrote:
The docker secrets are things like passwords and API keys. They are being stored in my dotfiles repository mainly as a backup along with the rest of my home server configuration.
That's sensible enough, although I would probably use 1Password secret injection https://developer.1password.com/docs/cli/secrets-config-files/ or something similar for running Docker and/or setting up the configuration files.
The permissions on the files are more of a 'just in case' scenario. I guess technically they don't need to be private and owned by root on the server.
So this is on a home server where you log in as user X to manage the server, and your running Docker images are configured to look for various API keys and such in ~x/docker-secrets/…, but right now you do chown root:root -R ~x/docker-secrets && chmod 0700 ~x/docker-secrets after writing them.
Especially if you’re not logged onto the server all the time, I would absolutely skip the chown dance (chezmoi can already handle most of the chmod as long as the user is yourself by naming it private_docker-secrets in the source state). If you are logged into the server all the time. If you’re worried about applications that you are running from doing this, I would set up a different chezmoi dotfiles repo and either make it deployed by root (this is allowed) or by a different, non-privileged user (this would be preferred).
— Reply to this email directly, view it on GitHub https://github.com/twpayne/chezmoi/issues/2879#issuecomment-1478736728, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAP7FG2D3OFQO4BCXDQO6S3W5I5G3ANCNFSM6AAAAAAWB6IPAY . You are receiving this because you authored the thread.Message ID: @.***>
+1 on everything that @halostatue wrote.
Hopefully this is now resolved. Please re-open if needed.
What exactly are you trying to do?
I want to have my docker secrets encrypted and managed by chezmoi along with the rest of my HTPC setup.
What have you tried so far?
The secrets directory and files have permissions 600 and owned by root for security. The files are added to chezmoi with chezmoi add --encrypt and are added to the source with 'encrypted' and 'private'. All good so far.
I have run_before and run_after scripts that change permissions of the secrets folder temporarily to allow chezmoi access to decrypt the .age files into the secrets folder, and then set the correct ownership and permissions back to 600 root:root
If I want to add a new secret to chezmoi, I have to change perms back to 755 and chown to my username. Fiddly but doable.
chezmoi apply works fine as well. Perms are set, files are decrypted into the directory and set to 600 as required, and ownership is set back to root.
The issue is that chezmoi diff and\or re-add do not work because the secrets folder is owned by root at this point with 600 perms.
Is there a better way to achieve what I want to do.
Output of
chezmoi doctor
Additional context
Add any other context about the problem here.