-
-
Notifications
You must be signed in to change notification settings - Fork 605
Allow removal of old SSH keys on provision #1576
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
Allow removal of old SSH keys on provision #1576
Conversation
…e first non-empty SSH key Rel: roots#1087
|
🤔 seems useful because it's opt-in. I wonder if we should actually not even define this by default in |
So you'd end up with That would presumably mean that someone could set that as a Trellis CLI setting in their config file. Could be a pro or a con. I'm not married to either way. If you'd prefer this not to be added to |
Sort of, I mean the Ansible extra vars feature. So it would be used like this: They are just normal variables but take precedence. There's no way to set these in the CLI config; they can only be specified in the command like that. |
Gotcha, I'm glad I clarified as that's not what I thought you meant! Understood, I'll remove the entry in |
…ce using extra vars via CLI
Thank you 🚀 |
* Update SSH key removal docs Rel: roots/trellis#1576 * Update ssh-keys authors * Update SSH key removal docs Rel: roots/trellis#1576 * Update trellis/ssh-keys.md Co-authored-by: Scott Walkinshaw <[email protected]> --------- Co-authored-by: Scott Walkinshaw <[email protected]>
Rel: #1087
This PR adds the ability to enable removing old SSH keys from the server.
The added task replaces all SSH keys on the server for the users defined in Trellis with the first found SSH key set in
group_vars/all/users.yml
. This allows for cases where the Trellis defaults~/.ssh/id_rsa.pub
and~/.ssh/id_ed25519.pub
don't exist. The existing task "Add user SSH keys" then adds the remaining keys as usual.Given this has the power to lock a user out of their server, a flag has been added to allow making this an optional task to run. To enable, set
reset_user_ssh_keys: true
. I've placed this ingroup_vars/all/security.yml
but arguments can be made for this inusers.yml
ormain.yml
.Scenarios
Given the default Trellis keys:
If...
~/.ssh/id_rsa.pub
does not exist,~/.ssh/id_ed25519.pub
does existkeys
becomes["", "ssh-ed25519 AAAAC3NzaC1.."]
(example)select('truthy')
filters out empty strings,keys
becomes["ssh-ed25519 AAAAC3NzaC1.."]
~/.ssh/id_ed25519.pub
is used (e.g.ssh-ed25519 AAAAC3NzaC1..
)~/.ssh/id_ed25519.pub
.~/.ssh/id_rsa.pub
nor~/.ssh/id_ed25519.pub
existkeys
becomes["", ""]
select('truthy')
filters out empty strings,keys
becomes[]
when
clause(item['keys'] | select('truthy') | list | length) > 0
evaluates to false