Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need to hard code user key paths #53

Closed
gabysbrain opened this issue Sep 2, 2021 · 5 comments
Closed

need to hard code user key paths #53

gabysbrain opened this issue Sep 2, 2021 · 5 comments

Comments

@gabysbrain
Copy link
Contributor

I have a few keys which are only encrypted with my user ssh keys to keep them consistent across systems. On a nixos-rebuild switch I was getting an error:

decrypting /nix/store/ddsxinl7ixlmfhlay848zy8qg916f1ks-google-vdirsyncer.age to /run/secrets/google-vdirsyncer...
Error: No matching keys found

[ Did rage not do what you expected? Could an error be more useful? ]
[ Tell us: https://str4d.xyz/rage/report                            ]
chmod: cannot access '/run/secrets/google-vdirsyncer.tmp': No such file or directory
chown: cannot access '/run/secrets/google-vdirsyncer.tmp': No such file or directory
mv: cannot stat '/run/secrets/google-vdirsyncer.tmp': No such file or directory

I traced this down to the fact that age,sshKeyPaths defaults to only the system rsa and ed25519 keys but does not try and look in user directories. Is this intentional? If so, I can update the documentation to reflect this but otherwise this will need some changes to the nixos module.

Thanks for an awesome package! This has made things so much easier!

@ryantm
Copy link
Owner

ryantm commented Sep 2, 2021

@gabysbrain Are you saying you were expecting it to look into all the user's ~/.ssh directories for decryption keys by default? Currently it only looks in /etc/ssh.

I hadn't really thought about considering the home directories, because in my use case the home directories rarely have private SSH keys. Seems like maybe it would be fine to check there, but I hope some other people can help me think through the security implications.

@gabysbrain
Copy link
Contributor Author

Yes, that's what I'd like.

The reason this would help is I have a few secrets that I encrypt for my local user so it would be easier to just encrypt it with my personal host key rather than updating the key every time I add or remove a system from my nix deployment. It's not a huge deal right now. I just override the secrets files in the config but it would be nice, since you can encrypt keys with your personal ssh key, that it would automatically decode them as well.

But you're right, I'm not sure of the security implications either.

@asymmetric
Copy link
Contributor

I tried thinking of possible security drawbacks, but none came to mind.

Still, it could be a good idea to keep this behaviour off by default, behind a config flag.

@gabysbrain
Copy link
Contributor Author

#58 basically does what I'm requesting here. I would suggest to close this as duplicate

@ryantm
Copy link
Owner

ryantm commented Mar 9, 2022

Thinking about this again, I think I see at least one security problem:

Alice and Mallory share a machine configured by Bob. Mallory has Alice's encrypted secret for her other unrelated machine which she publishes in her public GitHub repo. Mallory convinces Bob to incorporate the encrypted secret into the machine's configuration, then when Bob deploys, the activation script reads Alice's home directory private key and decrypts the secret for Mallory.

Though this security problem isn't too common these days as few people share machines in this way. Alice should not put her private key on a machine shared with people she doesn't trust.

@ryantm ryantm closed this as completed Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants