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

UX improvements for tbot #10833

Merged
merged 12 commits into from
Mar 10, 2022
Merged

UX improvements for tbot #10833

merged 12 commits into from
Mar 10, 2022

Conversation

timothyb89
Copy link
Contributor

@timothyb89 timothyb89 commented Mar 4, 2022

A last batch of UX tweaks for 9.0:

@timothyb89
Copy link
Contributor Author

I know there's a few other renames being discussed in #10030

I do like the -lifetime suffix and can still make that change tctl/tbot if we'd like.

For context, here's the tbot start syntax as of this PR:

$ ./tbot start --help
usage: tbot start [<flags>]

Starts the renewal bot, writing certificates to the data dir at a set interval.

Flags:
  -d, --debug             Verbose logging to stdout
  -c, --config            tbot.yaml path
  -a, --auth-server       Specify the Teleport auth server host
      --token             A bot join token, if attempting to onboard a new bot; used on first connect.
      --ca-pin            A repeatable auth server CA hash to pin; used on first connect.
      --data-dir          Directory to store internal bot data.
      --destination-dir   Directory to write generated certificates
      --certificate-ttl   TTL of generated certificates
      --renewal-interval  Interval at which certificates are renewed; must be less than the certificate TTL.
      --join-method       Method to use to join the cluster.
      --oneshot           If set, quit after the first renewal.

tbot init:

usage: tbot init --bot-user=BOT-USER [<flags>]

Initialize a certificate destination directory for writes from a separate bot user.

Flags:
  -d, --debug            Verbose logging to stdout
  -c, --config           tbot.yaml path
      --destination-dir  If NOT using a config file, specify the destination directory.
      --init-dir         If using a config file and multiple destinations are configured, specify which to initialize
      --clean            If set, remove unexpected files and directories from the destination
      --bot-user         Name of the bot Unix user which should have write access to the destination.

Aliases:

tctl bots add:

usage: tctl bots add --roles=ROLES [<flags>] <name>

Add a new certificate renewal bot to the cluster.

Flags:
  -d, --debug        Enable verbose logging to stderr
  -c, --config       Path to a configuration file [/etc/teleport.yaml]. Can also be set via the TELEPORT_CONFIG_FILE environment variable.
      --auth-server  Attempts to connect to specific auth/proxy address(es) instead of local auth [127.0.0.1:3025]
  -i, --identity     Path to an identity file. Must be provided to make remote connections to auth. An identity file can be exported with 'tctl auth sign'
      --insecure     When specifying a proxy address in --auth-server, do not verify its TLS certificate. Danger: any data you send can be intercepted or modified by an attacker.
      --roles        Roles the bot is able to assume.
      --ttl          TTL for the bot join token.
      --token        Name of an existing token to use.

Args:
  <name>  A name to uniquely identify this bot in the cluster.

Aliases:

@timothyb89 timothyb89 force-pushed the timothyb89/tbot-ux branch 3 times, most recently from 2e2f690 to 5f8a8db Compare March 8, 2022 02:43
@benarent
Copy link
Contributor

benarent commented Mar 8, 2022

@timothyb89 When trying the above, I'm unable to use --token when using tctl bots add

tctl bots add --roles=access --token=blah terminator
ERROR: unknown long flag '--token'

@timothyb89
Copy link
Contributor Author

@timothyb89 When trying the above, I'm unable to use --token when using tctl bots add

tctl bots add --roles=access --token=blah terminator
ERROR: unknown long flag '--token'

Hmm, that definitely should work. My initial guess is that you might have an outdated tctl, but I'll dig into this more tomorrow.

tool/tbot/config/config.go Show resolved Hide resolved
tool/tbot/config/config.go Show resolved Hide resolved
const exampleConfigFile = `
auth_server: auth.example.com
renew_interval: 5m
renewal_interval: 5m
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any docs that need to be updated for this rename?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the docs PR (#10775) doesn't refer to this config parameter at all, luckily.

tool/tbot/config/configtemplate_ssh.go Outdated Show resolved Hide resolved
@@ -144,6 +155,10 @@ func onWatch(botConfig *config.BotConfig) error {
}

func onStart(botConfig *config.BotConfig) error {
if botConfig.AuthServer == "" {
return trace.BadParameter("An auth server must be set via --auth-server or configuration")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we support tunneling through proxy? If so, I recommend we change the wording to mention that it can be an auth or proxy server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will reword.

@@ -158,9 +173,12 @@ func onStart(botConfig *config.BotConfig) error {
var authClient auth.ClientI

// TODO: graceful shutdown via signal; see #7066
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove this TODO

@timothyb89 timothyb89 marked this pull request as ready for review March 9, 2022 18:20
@github-actions github-actions bot added the tctl tctl - Teleport admin tool label Mar 9, 2022
@github-actions github-actions bot requested review from codingllama and jakule March 9, 2022 18:20
@r0mant r0mant mentioned this pull request Mar 9, 2022
38 tasks
@timothyb89 timothyb89 force-pushed the timothyb89/tbot-ux branch 2 times, most recently from fa50d20 to 0e8c901 Compare March 10, 2022 02:19
Base automatically changed from timothyb89/tbot-init to master March 10, 2022 06:09
@codingllama
Copy link
Contributor

89 commits and 2.7k+ added lines is a tough review. Any chance we could split this into reasonably-sized parts?

@timothyb89
Copy link
Contributor Author

89 commits and 2.7k+ added lines is a tough review. Any chance we could split this into reasonably-sized parts?

Hrm, GitHub got confused over the merge base change, it's supposed to be just +300 or so. I'll try to fix it.

A last batch of UX tweaks for 9.0:
 - rename --renew-interval -> renewal-interval
 - add `--oneshot` mode to fetch one set of certs and exit (client
   side only, no server enforcement yet)
 - add `tbot version`
 - add unix signal handling: graceful exit on SIGINT, reload on
   SIGHUP/SIGUSR1
 - make auth server an optional config option and check it only when
   needed (i.e. `tbot start`)
@timothyb89
Copy link
Contributor Author

Alright, apologies for confusion, the diff should now be back under control. Hopefully +230/-50 is a little more sane 🙂

tool/tbot/config/config.go Show resolved Hide resolved
tool/tbot/config/config_test.go Outdated Show resolved Hide resolved
func parseSSHVersion(versionString string) (*semver.Version, error) {
versionTokens := strings.Split(versionString, " ")
if len(versionTokens) == 0 {
return nil, trace.Errorf("invalid version string: %s", versionString)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: prefer BadParameter to Errorf?

Suggested change
return nil, trace.Errorf("invalid version string: %s", versionString)
return nil, trace.BadParameter("invalid version string: %s", versionString)

Same for others.

@@ -111,18 +175,31 @@ func (c *TemplateSSHClient) Render(ctx context.Context, authClient auth.ClientI,
return trace.Wrap(err)
}

// Default to including the RSA deprecation workaround.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the RSA workaround? Do we have it explained somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add an explainer comment to the IncludeRSAWorkaround docstring:

IncludeRSAWorkaround controls whether the RSA deprecation workaround is included in the generated configuration. Newer versions of OpenSSH deprecate RSA certificates and, due to a bug in golang's ssh package, Teleport wrongly advertises its unaffected certificates as a now-deprecated certificate type. The workaround includes a config override to re-enable RSA certs for just Teleport hosts, however it is only supported on OpenSSH 8.5 and later.

tool/tbot/main.go Outdated Show resolved Hide resolved
tool/tbot/main.go Outdated Show resolved Hide resolved
@@ -144,6 +155,10 @@ func onWatch(botConfig *config.BotConfig) error {
}

func onStart(botConfig *config.BotConfig) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but we should consider refactoring the bulk of this logic outside of package main and test it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there's a lot of cleanup and refactoring needed here. Hoping to prioritize that sooner rather than later 🙂

@codingllama
Copy link
Contributor

Alright, apologies for confusion, the diff should now be back under control. Hopefully +230/-50 is a little more sane 🙂

Much better :)

@timothyb89 timothyb89 enabled auto-merge (squash) March 10, 2022 19:57
@timothyb89 timothyb89 merged commit bea5f7f into master Mar 10, 2022
@timothyb89 timothyb89 deleted the timothyb89/tbot-ux branch March 10, 2022 20:41
timothyb89 added a commit that referenced this pull request Mar 10, 2022
* UX improvements for tbot

A last batch of UX tweaks for 9.0:
 - rename --renew-interval -> renewal-interval
 - add `--oneshot` mode to fetch one set of certs and exit (client
   side only, no server enforcement yet)
 - add `tbot version`
 - add unix signal handling: graceful exit on SIGINT, reload on
   SIGHUP/SIGUSR1
 - make auth server an optional config option and check it only when
   needed (i.e. `tbot start`)

* Remove `--auth-server` flag from `tbot init` example

* Add `cut` workaround to allow connecting to nodes without DNS

* Update product name in tbot CLI help

* Add `--format=json` support to `tctl bots add`

* Detect OpenSSH version and conditionally remove the RSA deprecation workaround

* Fix failing unit test after rename

* Update tool/tbot/config/configtemplate_ssh.go

Co-authored-by: Zac Bergquist <[email protected]>

* Address review feedback

* Apply suggestions from code review

Co-authored-by: Alan Parra <[email protected]>

* Document IncludeRSAWorkaround and address review comments

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: Alan Parra <[email protected]>
timothyb89 added a commit that referenced this pull request Mar 11, 2022
* UX improvements for tbot

A last batch of UX tweaks for 9.0:
 - rename --renew-interval -> renewal-interval
 - add `--oneshot` mode to fetch one set of certs and exit (client
   side only, no server enforcement yet)
 - add `tbot version`
 - add unix signal handling: graceful exit on SIGINT, reload on
   SIGHUP/SIGUSR1
 - make auth server an optional config option and check it only when
   needed (i.e. `tbot start`)

* Remove `--auth-server` flag from `tbot init` example

* Add `cut` workaround to allow connecting to nodes without DNS

* Update product name in tbot CLI help

* Add `--format=json` support to `tctl bots add`

* Detect OpenSSH version and conditionally remove the RSA deprecation workaround

* Fix failing unit test after rename

* Update tool/tbot/config/configtemplate_ssh.go

Co-authored-by: Zac Bergquist <[email protected]>

* Address review feedback

* Apply suggestions from code review

Co-authored-by: Alan Parra <[email protected]>

* Document IncludeRSAWorkaround and address review comments

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: Alan Parra <[email protected]>

Co-authored-by: Zac Bergquist <[email protected]>
Co-authored-by: Alan Parra <[email protected]>
@webvictim webvictim mentioned this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-required machine-id tctl tctl - Teleport admin tool
Projects
None yet
5 participants