Skip to content

Ansible Node - Enforce private key permission and bind permissions to scylla user#141

Open
fee-mendes wants to merge 1 commit intoscylladb:masterfrom
fee-mendes:ssl_fix
Open

Ansible Node - Enforce private key permission and bind permissions to scylla user#141
fee-mendes wants to merge 1 commit intoscylladb:masterfrom
fee-mendes:ssl_fix

Conversation

@fee-mendes
Copy link
Member

When the source playbook is executed with become: True its relevant TLS certificates will be owned by root. This causes a problem, because later on when trying to copy we are unable to read the resulting private key file, as it is (correctly) created by default with mode 0600.

This commit let Ansible generate each PKI component with mode 0644. Then, ensure these are copied to the remote machine's with strict permissions to scylla user/group. Finally, ensure that the private key is only readable by its target user - both locally and remotely.

Fixes #139

loop:
- "./ssl/{{ inventory_hostname }}/{{ inventory_hostname }}.pem"

- name: Secure local OpenSSL private key
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Don't we want to cleanup after ourselves?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Updated to delete private key. Do notice we must still keep the private CA key for add-node operations, for instance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following why would you need to keep any key after you copied it to remote nodes?
We are going to re-generate all keys from scratch every time we execute the Role anyway, don't we?

… scylla user

When the source playbook is executed with `become: True` its relevant TLS certificates will be owned by root. This causes a problem, because later on when trying to copy we are unable to read the resulting private key file, as it is (correctly) created by default with mode 0600.

This commit let Ansible generate each PKI component with mode 0644. Then, ensure these are copied to the remote machine's with strict permissions to scylla user/group. Finally, ensure that the private key is only readable by its target user - both locally and remotely.

Fixes scylladb#139

- name: Delete local OpenSSL private key
file:
path: "./ssl/{{ inventory_hostname }}/{{ inventory_hostname }}.pem"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of keeping any file under .ssl on the localhost?

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

Successfully merging this pull request may close these issues.

TLS - Private key (insecure) copy fails when ansible is ran as a regular user

2 participants