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

RFD - Static host users #43666

Merged
merged 10 commits into from
Jul 17, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions rfd/0175-static-host-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
author: Andrew Burke ([email protected])
state: draft
---

# RFD 175 - Static Host Users

## Required Approvers

- Engineering: @rosstimothy && @lxea && @@espadolini

## What

Teleport nodes will be able to create host users statically, i.e. independently
of a Teleport user creating one when SSHing with the current host user creation.

## Why

Host users can be created and used (potentially by third-party services) without
a Teleport user needing to log in first.

## Details

### UX

To create a static host user, an admin will create a `static_host_user` resource:

```yaml
# foo-dev.yaml
kind: static_host_user
metadata:
name: foo-dev
spec:
login: foo
node_labels:
env: dev
```

Then create it with `tctl`:

```code
$ tctl create foo-dev.yaml
```

The user `foo` will eventually appear on nodes with label `env: dev` once the
`foo-dev` resource makes it through the cache.

To update an existing static host user, an admin will update update `foo-dev.yaml`,
then update the resource in Teleport with `tctl`:

```code
$ tctl create -f foo-dev.yaml
```

To remove the resource and delete all host users associated with it, an admin will run:

```code
$ tctl rm host_user/foo-dev
```

### Resource

We will add a new resource to Teleport called `static_host_user`. This resource defines
rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
a single host user, including groups, sudoers entitlements, uid, and gid, as well as labels
to select specific nodes the user should be created on.

```yaml
kind: static_host_user
metadata:
name: hostuser
spec:
login: user1
# groups and sudoers are identical to their role counterparts
groups: [abc, def]
sudoers: [
# ...
]
# same as from user traits
uid: "1234"
gid: "5678"
# same as allow rules in roles
node_labels:
# ...
node_labels_expression: # ...
```

### Propagation

On startup, nodes will apply all available `static_host_user`s in the cache,
then watch the cache for new and updated users. Nodes will use the labels in the
`static_host_user`s to filter out those that don't apply to them, with the same
logic that currently determines access with roles. Updated `static_host_user`s
override the existing user.

Nodes that disable host user creation (by setting `ssh_service.disable_create_host_user`
to true in their config) will ignore `static_host_user`s entirely.

### Deletion

Delete events from the cache will signal the node to delete a created user. If
rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
the user is still in use (i.e. someone is logged in as it), it will be added
to the `teleport-delete` group. Teleport will periodically delete `teleport-delete`
users as it does with expired `teleport-system` users. Teleport users will not
be able to log in as a host user if it is marked for deletion.

To facilitate deletion, `static_host_user`s will be keyed under their login in
the backend, i.e. `hostUsers/<login>/<resource-name>`.

### Product usage

The session start PostHog event can be extended to include a flag
indicating whether or not the host user for an SSH session was
created by Teleport (for both static and non-static host users).

### Security

We want to minimize the ability of Teleport users to mess with existing host users
rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
via `static_host_user`s. To that end, all host users created from `static_host_user`s
will be in the `teleport-created` group (similar to the `teleport-system` group, which
we currently use to mark users that Teleport should clean up). Teleport will not
delete users not in `teleport-created`, and new users will not override existing users
that are not in `teleport-created`.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about existing, potentially ephemeral users in teleport-system? Will they be adopted into teleport-created? If so we'd have to be careful about what happens right around the Teleport upgrade that introduces this feature, if the cluster is already configured for it. I think that we could make the case that if the user is not ephemeral then there's no real reason to override it - and if it is ephemeral, it will eventually get cleaned up by not having a session and then the static configuration can kick in "naturally".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, they won't be adopted. All users in teleport-system are ephemeral, so conflicts will be resolved after a session ends just as you described. In any case, I've renamed teleport-created to teleport-static to make it clearer that it's for marking static users, not all Teleport-created users.


rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
### Backward compatibility

Consider nodes that do not support static host users but are connected to an
auth server that does. These nodes will silently ignore static
host users. When these nodes are upgraded to a supporting
version, they will create static host users as normal.

rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
### Future work

Extend server heartbeats to include static host users. This will allow Teleport
users to spot incorrect propagation of host users due to misconfiguration, nodes
that don't support them, etc.
Loading