Skip to content

Reload SSH Agent Identities - #13625

Open
kaposnick wants to merge 3 commits into
keepassxreboot:developfrom
kaposnick:pr_reload_sshagent_keys
Open

kaposnick wants to merge 3 commits into
keepassxreboot:developfrom
kaposnick:pr_reload_sshagent_keys

Conversation

@kaposnick

Copy link
Copy Markdown
Contributor

Fixes #12180
This PR adds a "Reload SSH Keys" action that re-adds any previously-added SSH identities but are currently gone from the ssh-agent. A useful application of this feature, as stated in #12180 , is when the ssh-agent is restarted and the identities are missing. The user will now have the option to reload the already loaded keys.

Screenshots

Testing strategy

Manual GUI Testing

I first verified it using the GUI. I launched the ssh-agent:

  • eval $(ssh-agent -s -a /tmp/ssh-agent-test
  • In the GUI, I made sure that I set the SSH_AUTH_SOCK_OVERRIDE to /tmp/ssh-agent-test
  • I click on an entry with an SSH key and select Add key to SSH Agent
    • ssh-add -l should now list this key.
  • Stop the ssh agent using ssh-agent -k
    • ssh-add -l should not list the key.
  • Restart the ssh-agent: eval $(ssh-agent -s -a /tmp/ssh-agent-test. Without this PR, there was no way for the previously loaded keys to be reloaded.
  • Select Tools > Reload SSH Keys
  • ssh-add -l should list again the key.

Unit Testing

Enhanced TestSSHAgent.cpp coverage specifically for reloadAllAgentIdentities(). All the new and old tests in testsshagent pass locally.

Type of change

  • ✅ New feature (change that adds functionality)

@droidmonkey droidmonkey added feature: SSH agent pr: new feature Pull request adds a new feature labels Aug 26, 2026
@droidmonkey
droidmonkey requested review from droidmonkey and a lite review from Copilot August 26, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “Reload SSH Keys” feature to the SSH agent integration so KeePassXC can re-add previously-added identities that have disappeared from the running agent (e.g., after an agent restart), without requiring a database reopen. This fits into the existing SSH agent lifecycle handling in src/sshagent and is surfaced as a Tools menu action in the main window.

Changes:

  • Introduces tracking metadata (SshKeySettings) and implements SSHAgent::reloadAllAgentIdentities() to re-add missing identities from currently open/unlocked databases.
  • Adds a new GUI action (“Reload SSH Keys”) wired into MainWindow and the Tools menu.
  • Expands testsshagent coverage with several unit tests targeting reload behavior and edge cases.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/TestSSHAgent.h Adds new reload-focused test declarations and a helper for building a test entry/database.
tests/TestSSHAgent.cpp Implements multiple reload regression tests and updates calls to the new addIdentity() signature.
src/sshagent/SSHAgent.h Adds SshKeySettings, changes addIdentity() API, and declares reloadAllAgentIdentities().
src/sshagent/SSHAgent.cpp Implements reload logic and updates internal key tracking to store settings.
src/gui/MainWindow.ui Adds the “Reload SSH Keys” QAction under Tools.
src/gui/MainWindow.h Declares the new reloadSSHAgentKeys() slot.
src/gui/MainWindow.cpp Wires the new action, gathers open DBs, and triggers reload from the UI.
src/gui/entry/EditEntryWidget.cpp Updates “Add key to SSH Agent” to pass SshKeySettings.
src/gui/DatabaseWidget.cpp Updates “Add to Agent” flow to pass SshKeySettings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/gui/MainWindow.cpp Outdated
Comment thread src/sshagent/SSHAgent.cpp Outdated
Comment thread src/sshagent/SSHAgent.h
Comment thread src/sshagent/SSHAgent.h
Comment thread src/gui/MainWindow.ui
Signed-off-by: Nikos Apostolakis <nikosapostolakis94@gmail.com>
Signed-off-by: Nikos Apostolakis <nikosapostolakis94@gmail.com>
Signed-off-by: Nikos Apostolakis <nikosapostolakis94@gmail.com>
@kaposnick
kaposnick force-pushed the pr_reload_sshagent_keys branch from f86cc5f to df1c2e8 Compare August 28, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: SSH agent pr: new feature Pull request adds a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to reconnect auto-loaded ssh keys

3 participants