-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
696bf61
to
6223db1
Compare
/excludeflake * |
77fb730
to
438c0f5
Compare
} | ||
|
||
// If "tsh ssh" is invoked the user must specify some host to connect to. | ||
if cf.UserHost == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow why we had to make the argument optional in kingpin and validate it here. Can we leave a comment explaining why this was necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to support tsh ssh -V
which can run without any additional arguments. I'll update the comment to explain why I had to remove Required()
from that Arg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this affect the usage docs badly? I reckon that everyone would likely figure out that sshing into an unspecified destination is never going to work, but still...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does.
Adding Required()
removes the square brackets from --help
output.
Not ideal, but I can update the help text to indicate this is a required argument.
Output of tsh ssh --help
before:
$ tsh ssh --help
usage: tsh ssh [<flags>] <[user@]host> [<command>...]
Run shell or execute a command on a remote SSH node.
Flags:
[...]
Args:
<[user@]host> Remote hostname and the login to use
[<command>] Command to execute on a remote host
Aliases:
Output of tsh ssh --help
after this PR:
$ tsh ssh --help
usage: tsh ssh [<flags>] [<[user@]host>] [<command>...]
Run shell or execute a command on a remote SSH node.
Flags:
[...]
Args:
[<[user@]host>] Remote hostname and the login to use, this argument is required
[<command>] Command to execute on a remote host
Aliases:
What do you guys think?
} | ||
|
||
// If "tsh ssh" is invoked the user must specify some host to connect to. | ||
if cf.UserHost == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this affect the usage docs badly? I reckon that everyone would likely figure out that sshing into an unspecified destination is never going to work, but still...
dcabbb5
to
f75370e
Compare
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".
f75370e
to
50ea203
Compare
/excludeflake * |
// If "tsh ssh" is invoked with the "-t" or "-T" flag, manually validate | ||
// "-t" and "-T" flags for "tsh ssh" due to the lack of inverse short flags | ||
// in kingpin. | ||
if cf.Interactive && cf.NonInteractive { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already use a fork of kingpin, would it be worth investigating adding support in kingpin instead of all of the various workarounds that we've had to introduce in this PR to overcome its shortcomings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rosstimothy That's what I originally did and even had a working implementation.
I don't remember all the details, but during testing I found that the way we hook kingpin for terminate (which I would have to use) is broken and the fact that tsh
does not panic often is incidental. Fixing this would have been a fairly big undertaking because we hook termination from tsh
.
This is what I have in my notes:
https://github.com/gravitational/kingpin/blob/master/app.go#L617
None of those `a.terminate(1)` will actually exit due to how we hook the terminate function
in Teleport, which means things will not be set downstream and panic when it flows through
the rest of kingpin code.
This FatalIfError is called all over the place in kingpin.
https://github.com/gravitational/kingpin/blob/master/app.go#L642C23-L642C35
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".
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".
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".
Added support for OpenSSH compatibility flags for interactivity (
-t
and-T
) and version information (-V
). This is for customers that aliasssh
totsh ssh
.changelog: Added support for
-t
,-T
, and-V
flags totsh
for OpenSSH compatibility.