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

Secure Persistant Storage of Digital Ocean Auth Keys #942

Open
ixxie opened this issue May 3, 2018 · 4 comments
Open

Secure Persistant Storage of Digital Ocean Auth Keys #942

ixxie opened this issue May 3, 2018 · 4 comments

Comments

@ixxie
Copy link

ixxie commented May 3, 2018

Quoting the Digital Ocean chapter of the NixOps manual on how to store the authentication token for the Digital Ocean backend:

[..] have the DIGITAL_OCEAN_AUTH_TOKEN set with an authentication token, obtained from the Digital Ocean console. The token can also be provided via the deployment.digitalOcean.authToken option.

I am no security guru, but this strikes me as a little insecure? I am wondering how to persist the environment variable or configuration option in a more secure way; are there best practices or tools that allow me to avoid having to store my authentication token in the clear?

@nh2
Copy link
Contributor

nh2 commented May 8, 2018

There are only two key choices: You store it on the machine to require no user input, or you don't.

Any form of encryption that doesn't require user input is almost analogous to clear text; an attacker obtaining access to the machine will be able to unlock it without user input.

If you require user input, you might as well just require the credential itself as input.

The way it's common with AWS is that your credentials are stored in clear text in ~/.aws/credentials. Such a scheme is always better than putting your clear text credentials into your .nix file because it allows you to check in the .nix file into the repo (no credentials in source repositories), and to chown 600 the credentials file so that only your user can see it.

You can do things like deployment.digitalOcean.authToken = builtins.readFile ... to implement that scheme for DigitalOcean.

But I doubt that NixOps itself can provide a better story for "storing" these keys than you can yourself.

Does that make sense?

@ixxie
Copy link
Author

ixxie commented May 8, 2018

@nh2 makes a lot of sense; I guess a nice compromise between security and convenience would be to encrypt all the keys for NixOps using one password; a password is certainly easier to memorize than an authentication key!

I imagine it would be difficult to implement as a feature, but reasonable to implement for a personal configuration, by - for example - encrypting a /secrets folder. I guess the tricky bit is finding a convenient way to 'wrap' the nixops CLI with the decryption logic.

@nh2
Copy link
Contributor

nh2 commented May 8, 2018

@ixxie I think the way I would do that is to wrap nixops that can fetch your password by running a command, and store it in an environment variable like DIGITAL_OCEAN_AUTH_TOKEN for the nixops invocation.

For example, for Hetzner I use (roughly) this bash script to wrap nixops to prompt me for my Hetzner password:

read -p 'Enter Hetzner subaccount password: ' -s password && echo && HETZNER_ROBOT_PASS="$password" nixops $@

That way you can externalise the password storage and make it the responsibility of another program, for example, you could

  • invoke pass or gpg
  • contact Vault
  • invoke some other password storage program

@ixxie
Copy link
Author

ixxie commented May 19, 2018

@nh2 - sounds good; once I will figure out how to fix #945 and get my NixOps deployment ready, I will try this out and hopefully also document the whole think in the NixOS Wiki (which so far is a bit low on NixOps contributions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants