diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index 1a8f73b7db6af..80d4e8b2b3e5e 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -1361,9 +1361,6 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { case login.FullCommand(): err = onLogin(&cf) case logout.FullCommand(): - if err := refuseArgs(logout.FullCommand(), args); err != nil { - return trace.Wrap(err) - } err = onLogout(&cf) case show.FullCommand(): err = onShow(&cf) @@ -2211,9 +2208,10 @@ func onLogout(cf *CLIConf) error { } fmt.Printf("Logged out all users from all proxies.\n") - default: - fmt.Printf("Specify --proxy and --user to remove keys for specific user ") - fmt.Printf("from a proxy or neither to log out all users from all proxies.\n") + case proxyHost != "" && cf.Username == "": + fmt.Printf("Specify --user to log out a specific user from %q or remove the --proxy flag to log out all users from all proxies.\n", proxyHost) + case proxyHost == "" && cf.Username != "": + fmt.Printf("Specify --proxy to log out user %q from a specific proxy or remove the --user flag to log out all users from all proxies.\n", cf.Username) } return nil } @@ -4257,19 +4255,6 @@ func parseCertificateCompatibilityFlag(compatibility string, certificateFormat s } } -// refuseArgs helper makes sure that 'args' (list of CLI arguments) -// does not contain anything other than command -func refuseArgs(command string, args []string) error { - for _, arg := range args { - if arg == command || strings.HasPrefix(arg, "-") { - continue - } else { - return trace.BadParameter("unexpected argument: %s", arg) - } - } - return nil -} - // flattenIdentity reads an identity file and flattens it into a tsh profile on disk. func flattenIdentity(cf *CLIConf) error { // Save the identity file path for later