Skip to content

feat(key): Trigger SSH agent reconnection after YubiKey release#218

Open
hnw wants to merge 1 commit intostr4d:mainfrom
hnw:feature/trigger-ssh-agent-reconnect
Open

feat(key): Trigger SSH agent reconnection after YubiKey release#218
hnw wants to merge 1 commit intostr4d:mainfrom
hnw:feature/trigger-ssh-agent-reconnect

Conversation

@hnw
Copy link

@hnw hnw commented Jan 4, 2026

Description:

Currently, age-plugin-yubikey sends SIGHUP to the SSH agent to release the YubiKey PIV applet. However, many agents do not automatically reconnect, causing the YubiKey to remain idle. This idle state leads to a loss of the PIN cache due to OS power-saving features.

This PR introduces a "poke" mechanism that sends an SSH_AGENTC_REQUEST_IDENTITIES message to the SSH_AUTH_SOCK immediately after the plugin disconnects from the YubiKey.

Key Changes:

  • Implemented poke_ssh_agent() using standard UnixStream to minimize dependencies.
  • Ensures the correct sequence: Disconnect (Release) -> Poke (Reclaim) to avoid sharing violations.
  • Silent error handling to ensure the core encryption/decryption flow is never interrupted.

This improvement provides a seamless UX, especially for tools like sops, by preserving the PIN authentication state between operations.

Added a mechanism to send an SSH Agent Protocol request (Opcode 11) immediately after releasing the YubiKey handle. This triggers agents like yubikey-agent to reclaim the device on-demand, preventing PIN cache loss caused by OS power management during the "idle" period.
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

Successfully merging this pull request may close these issues.

1 participant