diff --git a/command/crypto/keypair.go b/command/crypto/keypair.go index 870fae2f9..e01099318 100644 --- a/command/crypto/keypair.go +++ b/command/crypto/keypair.go @@ -1,6 +1,9 @@ package crypto import ( + "fmt" + "os" + "github.com/pkg/errors" "github.com/smallstep/cli/crypto/keys" "github.com/smallstep/cli/crypto/pemutil" @@ -183,6 +186,12 @@ func createAction(ctx *cli.Context) (err error) { } else { var pass []byte pass, err = ui.PromptPassword("Please enter the password to encrypt the private key", ui.WithValue(password), ui.WithValidateNotEmpty()) + var pe *os.PathError + if errors.As(err, &pe) { + if pe.Op == "open" && pe.Path == "/dev/tty" { + return fmt.Errorf("could not read password to encrypt the private key: %w", err) + } + } if err != nil { return errors.Wrap(err, "error reading password") }