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

Prompt for PIN on tpm-backed ssh keys #4018

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkg/commands/oscommands/cmd_obj_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,11 @@ func (self *cmdObjRunner) getCheckForCredentialRequestFunc() func([]byte) (Crede
`Password\s*for\s*'.+':`: Password,
`Username\s*for\s*'.+':`: Username,
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
`Enter\s*PIN\s*for\s*.+\s*key\s*.+:`: PIN,
`.*2FA Token.*`: Token,
// With a tpm, ssh prompts:
// Enter PIN for '%s':
// https://github.com/openssh/libopenssh/blob/05dfdd5f54d9a1bae5544141a7ee65baa3313ecd/ssh/ssh-pkcs11.c#L251
`Enter\s*PIN\s*for\s*.+\s*(key\s*.+|'.+'):`: PIN,
`.*2FA Token.*`: Token,
}

compiledPrompts := map[*regexp.Regexp]CredentialType{}
Expand Down
6 changes: 6 additions & 0 deletions pkg/commands/oscommands/cmd_obj_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ func TestProcessOutput(t *testing.T) {
output: "Enter PIN for key '123':",
expectedToWrite: "pin",
},
{
name: "tpm pin prompt",
promptUserForCredential: defaultPromptUserForCredential,
output: "Enter PIN for 'label':", // https://github.com/tpm2-software/tpm2-pkcs11/blob/d7fd660dd3ad2b8382afc57a768872032bd71d64/docs/SSH.md?plain=1#L86S
expectedToWrite: "pin",
},
{
name: "2FA token prompt",
promptUserForCredential: defaultPromptUserForCredential,
Expand Down