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

Added support for additional OpenSSH compatibility flags. #46879

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

russjones
Copy link
Contributor

@russjones russjones commented Sep 23, 2024

Added support for OpenSSH compatibility flags for interactivity (-t and -T) and version information (-V). This is for customers that alias ssh to tsh ssh.

changelog: Added support for -t, -T, and -V flags to tsh for OpenSSH compatibility.

@github-actions github-actions bot added size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Sep 23, 2024
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Outdated Show resolved Hide resolved
tool/tsh/common/tsh.go Show resolved Hide resolved
Added support for OpenSSH compatibility flags for interactivity (-t and
-T) and version information (-V). This is for customers that alias "ssh"
to "tsh ssh".
@russjones russjones force-pushed the rjones/openssh-interactive-flags branch from 696bf61 to 6223db1 Compare September 27, 2024 22:08
@gravitational gravitational deleted a comment from github-actions bot Sep 27, 2024
@gravitational gravitational deleted a comment from github-actions bot Sep 27, 2024
@russjones russjones requested a review from zmb3 September 30, 2024 21:33
@@ -801,6 +845,11 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error {
ssh.Flag("log-dir", "Directory to log separated command output, when executing on multiple nodes. If set, output from each node will also be labeled in the terminal.").StringVar(&cf.SSHLogDir)
ssh.Flag("no-resume", "Disable SSH connection resumption").Envar(noResumeEnvVar).BoolVar(&cf.DisableSSHResumption)
ssh.Flag("relogin", "Permit performing an authentication attempt on a failed command").Default("true").BoolVar(&cf.Relogin)
// The following flags are OpenSSH compatibility flags. They are not
// implemented in Kingpin but are registered here to inform developers that
// they are being used. Their behavior is implemented in 000000.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the 00000 meant to reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Planning on putting the commit into this once I've pushed all changes.

@russjones russjones removed the request for review from klizhentas October 1, 2024 20:03
Comment on lines 713 to 723
if slices.Contains(cmdline, "-V") {
modules.GetModules().PrintVersion()

return nil, &common.ExitCodeError{
Code: 0,
}
}
i := slices.Index(cmdline, "-T")
if i > 0 {
cmdline = slices.Replace(cmdline, i, i+1, []string{"--no-tty"}...)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't handle short options grouped together in a single argument.

Kingpin's behavior already prohibits repeated short boolean flags AFAICT, so we could just have a secondary hidden flag for T and error out if both t and T are passed in (even though this would still technically be in violation of the OpenSSH cli api, since that follows "last option wins" instead).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@espadolini That's how I originally implemented this feature. @zmb3 you were not a fan, what do you think?

I don't have strong feelings either way.

@russjones
Copy link
Contributor Author

/excludeflake *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants