Skip to content

Commit

Permalink
Fix (tsh ssh -V).
Browse files Browse the repository at this point in the history
  • Loading branch information
russjones committed Aug 8, 2024
1 parent e891855 commit 10fa895
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tool/tsh/common/tsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ type CLIConf struct {
Interactive bool
// TODO(russjones)
NonInteractive bool
// TODO(russjones)
ShowVersion bool
// Quiet mode, -q command (disables progress printing)
Quiet bool
// Namespace is used to select cluster namespace
Expand Down Expand Up @@ -773,7 +775,7 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error {
// ssh
// Use Interspersed(false) to forward all flags to ssh.
ssh := app.Command("ssh", "Run shell or execute a command on a remote SSH node.").Interspersed(false)
ssh.Arg("[user@]host", "Remote hostname and the login to use").Required().StringVar(&cf.UserHost)
ssh.Arg("[user@]host", "Remote hostname and the login to use").StringVar(&cf.UserHost)
ssh.Arg("command", "Command to execute on a remote host").StringsVar(&cf.RemoteCommand)
app.Flag("jumphost", "SSH jumphost").Short('J').StringVar(&cf.ProxyJump)
ssh.Flag("port", "SSH port on a remote host").Short('p').Int32Var(&cf.NodePort)
Expand All @@ -785,6 +787,8 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error {
ssh.Flag("tty", "Allocate TTY").Short('t').BoolVar(&cf.Interactive)
// Use -T to not allocate a TTY.
ssh.Flag(uuid.New().String(), "").Short('T').Hidden().BoolVar(&cf.NonInteractive)
// TODO(russjones)
ssh.Flag(uuid.New().String(), "").Short('V').Hidden().BoolVar(&cf.ShowVersion)
ssh.Flag("cluster", clusterHelp).Short('c').StringVar(&cf.SiteName)
ssh.Flag("option", "OpenSSH options in the format used in the configuration file").Short('o').AllowDuplicate().StringsVar(&cf.Options)
ssh.Flag("no-remote-exec", "Don't execute remote command, useful for port forwarding").Short('N').BoolVar(&cf.NoRemoteExec)
Expand Down Expand Up @@ -1284,6 +1288,16 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error {
cf.Interactive = false
}

// If "tsh ssh -V" was executed, Teleport is in OpenSSH compatibility mode,
// show the version and exit.
if cf.ShowVersion {
modules.GetModules().PrintVersion()
return nil
}
if cf.UserHost == "" {
return trace.BadParameter("required argument '[user@]host' not provided")
}

// Did we initially get the Username from flags/env?
cf.ExplicitUsername = cf.Username != ""

Expand Down

0 comments on commit 10fa895

Please sign in to comment.