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

vault ssh may print misleading warning message #19785

Closed
pschulten opened this issue Mar 28, 2023 · 3 comments
Closed

vault ssh may print misleading warning message #19785

pschulten opened this issue Mar 28, 2023 · 3 comments
Labels
bug Used to indicate a potential bug core/cli

Comments

@pschulten
Copy link

Describe the bug
#16683 changed the way vault generates warnings on potential errors regarding flags. This has a side effect when using vault ssh which now generates a (unhelpful) warning

To Reproduce
Steps to reproduce the behavior:

$ vault ssh -mode=ca -role=role -strict-host-key-checking=false -valid-principals=prince 10.227.12.248 -- pwd -P
Command flags must be provided before positional arguments. The following arguments will not be parsed as flags: [--,-P]
/home/prince

Expected behavior
No warning printed

Environment:

  • Vault Server Version (retrieve with vault status): 1.11.4
  • Vault CLI Version (retrieve with vault version): v1.13.0
  • Server Operating System/Architecture: macos (bash)

Additional context
Maybe stop parsing flags after the double dash. Workaround:

$ vault ssh -mode=ca -role=role -strict-host-key-checking=false -valid-principals=prince 10.227.12.248 -- pwd -P 2>/dev/null
/home/prince
@stevendpclark stevendpclark added core/cli bug Used to indicate a potential bug labels Mar 28, 2023
@hghaf099
Copy link
Contributor

hghaf099 commented May 2, 2023

Thanks for filing this ticket, and welcome to HashiCorp Vault community. The warning messages are not misleading as it informs the user which input arguments are not considered flags. Such a warning is not printed if you pass in the --format=json. The errors regarding flag errors are still printed if the flags are in the correct position:

$> vault ssh -mode=ca -role=role -strict-host-key-checking=false -notDefined=2 -valid-principals=prince 10.227.12.248
Command flags must be provided before positional arguments. The following arguments will not be parsed as flags: [-valid-principals=prince]
flag provided but not defined: -notDefined

I am going to close this issue for now. Please feel free to open a new ticket or if you have further concerns please let us know and we reopen the issue for further discussions.

@hghaf099 hghaf099 closed this as completed May 2, 2023
@maxb
Copy link
Contributor

maxb commented May 2, 2023

Hi @hghaf099 ,

I think this issue should be reopened, as it is reporting a genuine defect:

The vault ssh command has the unusual purpose of being a wrapper that invokes the real ssh command (after obtaining credentials). Moreover, the ssh command can take another command on its command line, to run on the remote machine. Because of this, there are multiple ways in which it can be a normal use-case for there to be option-like arguments later in the command line, which are deliberately intended either for ssh, or for a command being run via ssh on the remote machine.

This is quite unlike most other commands, where option-like things occurring after positional arguments are often a mistake.

It doesn't make sense to try to provide users with a helpful wrapper for Vault SSH operations, but then have it nag them with spurious warnings when they use it in the intended fashion.

@hghaf099
Copy link
Contributor

This issue should have been fixed. I am closing this, please feel free to reopen this issue or open a new one for further discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug core/cli
Projects
None yet
Development

No branches or pull requests

4 participants