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

Can't use --prompt=terminal with --ec2-server on Linux #1227

Open
2 of 3 tasks
cavoirom opened this issue Oct 31, 2023 · 2 comments
Open
2 of 3 tasks

Can't use --prompt=terminal with --ec2-server on Linux #1227

cavoirom opened this issue Oct 31, 2023 · 2 comments

Comments

@cavoirom
Copy link

cavoirom commented Oct 31, 2023

  • I am using the latest release of AWS Vault: v7.2.0.
  • I have provided my .aws/config (redacted if necessary)
  • I have provided the debug output using aws-vault --debug (redacted if necessary)

The --debug output.

$ sudo aws-vault --backend file --file-dir /<redacted>/.awsvault/keys exec default --debug --ec2-server
2023/10/31 03:25:47 aws-vault v7.2.0
2023/10/31 03:25:47 Using prompt driver: terminal
2023/10/31 03:25:47 Loading config file /root/.aws/config
2023/10/31 03:25:47 Parsing config file /root/.aws/config
2023/10/31 03:25:47 [keyring] Considering backends: [file]
aws-vault: error: exec: Can't use --prompt=terminal with --ec2-server. Specify a different prompt driver

The only prompt driver available on Linux is terminal. I have no choice to overcome the issue. I found this one is similar to #888

@MartinLoeper
Copy link

I am running into the same issue. We are using AWS Identity Center as SSO solution. It would be ideal if the background process would just open a browser window to re-authenticate if the session expires. Currently, there is no way to make this work since terminal is the only promp driver available. We do not even need a prompt driver for sso sessions...

@spirulence
Copy link

spirulence commented Mar 31, 2024

Until a fix is available - I have developed a gnarly workaround that can help us folks who are not using MFA yet. You need to fake the availability of an alternate prompt driver and tell aws-vault to use it.

AWS Vault uses the presence of executables in the system path in order to determine which prompt drivers are available. For example, to determine if kdialog is available, this method in prompt/kdialog.go is run:

func init() {

func init() {
	if _, err := exec.LookPath("kdialog"); err == nil {
		Methods["kdialog"] = KDialogMfaPrompt
	}
}

exec.LookPath comes from the Go standard library: https://pkg.go.dev/os/exec or https://pkg.go.dev/os/exec#LookPath

It's just looking for an executable with the right name in the system path to determine availability. So in my case, I duplicated a valid system executable, placed it in my user-specific binary directory and gave it the right name for kdialog:

cp /usr/bin/mv $HOME/bin/kdialog

I haven't tried using a shell script instead of a binary - with the appropriate permissions and shebang line it would probably work.

On my system I do have such a directory already added to my PATH. So now, the following works without issue:

aws-vault exec <profile> --server --prompt=kdialog

You could optimize this workaround a little more with two more tricks:

  1. use an environment variable for the prompt driver so you don't have to type it every time, AWS_VAULT_PROMPT
  2. add an executable to the current directory instead of in a system path: see this note at the bottom of the package docs:
Setting the environment variable GODEBUG=execerrdot=0 disables generation of ErrDot entirely, temporarily restoring the pre-Go 1.19 behavior for programs that are unable to apply more targeted fixes. A future version of Go may remove support for this variable.

Before adding such overrides, make sure you understand the security implications of doing so. See https://go.dev/blog/path-security for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants