Skip to content

Add credential prompts for PKCS11-based SSH keys #4646

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

Merged
merged 1 commit into from
Jun 20, 2025
Merged
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
1 change: 1 addition & 0 deletions pkg/commands/oscommands/cmd_obj_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func (self *cmdObjRunner) getCheckForCredentialRequestFunc() func([]byte) (Crede
`Username\s*for\s*'.+':`: Username,
`Enter\s*passphrase\s*for\s*key\s*'.+':`: Passphrase,
`Enter\s*PIN\s*for\s*.+\s*key\s*.+:`: PIN,
`Enter\s*PIN\s*for\s*'.+':`: PIN,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the problem domain at all, so not sure this makes sense, but do we have to match the single quotes explicitly, or the "key" in the previous pattern? Just wondering if we should combine the two PIN patterns into one, e.g. Enter\s*PIN\s*for\s*.+:.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are many cases which match Enter\s*PIN\s*for\s*.+: in OpenSSH, such as Enter PIN for CA key and Enter PIN for authenticator. Although these situations are not common during the SSH connection process established by git,, it is still worth considering handling different input conditions separately.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in #4018 I choose *(key\s*.+|'.+') to either match key ... or '...'

`.*2FA Token.*`: Token,
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/commands/oscommands/cmd_obj_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ func TestProcessOutput(t *testing.T) {
expectedToWrite: "passphrase",
},
{
name: "pin prompt",
name: "security key pin prompt",
promptUserForCredential: defaultPromptUserForCredential,
output: "Enter PIN for key '123':",
expectedToWrite: "pin",
},
{
name: "pkcs11 key pin prompt",
promptUserForCredential: defaultPromptUserForCredential,
output: "Enter PIN for '123':",
expectedToWrite: "pin",
},
{
name: "2FA token prompt",
promptUserForCredential: defaultPromptUserForCredential,
Expand Down