keepassxc-ssh-agent 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. keepassxc_ssh_agent-0.8.0/.github/dependabot.yml +10 -0
  2. keepassxc_ssh_agent-0.8.0/.github/workflows/auto-merge-dependabot.yml +32 -0
  3. keepassxc_ssh_agent-0.8.0/.github/workflows/auto-release.yml +38 -0
  4. keepassxc_ssh_agent-0.8.0/.github/workflows/lint_and_test.yml +56 -0
  5. keepassxc_ssh_agent-0.8.0/.github/workflows/pypi.yml +76 -0
  6. keepassxc_ssh_agent-0.8.0/.gitignore +216 -0
  7. keepassxc_ssh_agent-0.8.0/CLAUDE.md +74 -0
  8. keepassxc_ssh_agent-0.8.0/LICENSE +21 -0
  9. keepassxc_ssh_agent-0.8.0/PKG-INFO +246 -0
  10. keepassxc_ssh_agent-0.8.0/README.md +232 -0
  11. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/__init__.py +0 -0
  12. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/__main__.py +552 -0
  13. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/browser_client.py +401 -0
  14. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/config.py +100 -0
  15. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/server.py +198 -0
  16. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent/ssh_agent_protocol.py +126 -0
  17. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/PKG-INFO +246 -0
  18. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/SOURCES.txt +29 -0
  19. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/dependency_links.txt +1 -0
  20. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/entry_points.txt +2 -0
  21. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/requires.txt +5 -0
  22. keepassxc_ssh_agent-0.8.0/keepassxc_ssh_agent.egg-info/top_level.txt +1 -0
  23. keepassxc_ssh_agent-0.8.0/pyproject.toml +30 -0
  24. keepassxc_ssh_agent-0.8.0/setup.cfg +4 -0
  25. keepassxc_ssh_agent-0.8.0/tests/__init__.py +0 -0
  26. keepassxc_ssh_agent-0.8.0/tests/conftest.py +19 -0
  27. keepassxc_ssh_agent-0.8.0/tests/test_browser_client.py +281 -0
  28. keepassxc_ssh_agent-0.8.0/tests/test_config.py +134 -0
  29. keepassxc_ssh_agent-0.8.0/tests/test_main.py +311 -0
  30. keepassxc_ssh_agent-0.8.0/tests/test_server.py +181 -0
  31. keepassxc_ssh_agent-0.8.0/tests/test_ssh_agent_protocol.py +150 -0
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ - package-ecosystem: "pip"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "weekly"
@@ -0,0 +1,32 @@
1
+ name: Auto Merge Dependabot
2
+ on:
3
+ pull_request:
4
+ types:
5
+ - opened
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ pull-requests: write
11
+ contents: write
12
+
13
+ jobs:
14
+ auto-merge:
15
+ name: Auto Merge Dependabot PR
16
+ runs-on: ubuntu-24.04
17
+ if: github.actor == 'dependabot[bot]'
18
+ steps:
19
+ - uses: actions/checkout@v6
20
+ - uses: actions/create-github-app-token@v2
21
+ id: generate-token
22
+ with:
23
+ app-id: ${{ secrets.APP_ID_MERGE }}
24
+ private-key: ${{ secrets.APP_PRIVATE_KEY_MERGE }}
25
+ - name: Enable Pull Request Automerge
26
+ run: gh pr merge --squash --auto "${{ github.event.pull_request.number }}"
27
+ env:
28
+ GH_TOKEN: ${{ steps.generate-token.outputs.token }}
29
+ - name: Auto approve
30
+ run: gh pr review --approve "${{ github.event.pull_request.number }}"
31
+ env:
32
+ GH_TOKEN: ${{ steps.generate-token.outputs.token }}
@@ -0,0 +1,38 @@
1
+ name: Auto Release
2
+ on:
3
+ pull_request:
4
+ types:
5
+ - closed
6
+
7
+ jobs:
8
+ auto-release:
9
+ if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'pip')
10
+
11
+ name: Auto Release
12
+ runs-on: ubuntu-24.04
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v6
16
+ with:
17
+ fetch-depth: 0
18
+ - name: Get Version
19
+ id: get-version
20
+ run: |
21
+ LATEST_TAG=$(curl -s "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/latest" | jq -r '.name')
22
+ # Strip leading 'v' if present
23
+ VERSION="${LATEST_TAG#v}"
24
+ # Parse semver components
25
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
26
+ # Bump minor, reset patch
27
+ MINOR=$((MINOR + 1))
28
+ PATCH=0
29
+ echo "version=v${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_OUTPUT
30
+ - uses: actions/create-github-app-token@v2
31
+ id: generate-token
32
+ with:
33
+ app-id: ${{ secrets.APP_ID_MERGE }}
34
+ private-key: ${{ secrets.APP_PRIVATE_KEY_MERGE }}
35
+ - name: Create Release
36
+ run: gh release create ${{ steps.get-version.outputs.version }} --generate-notes
37
+ env:
38
+ GH_TOKEN: ${{ steps.generate-token.outputs.token }}
@@ -0,0 +1,56 @@
1
+ name: Python Lint and Test
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ paths-ignore:
8
+ - "**.md"
9
+ push:
10
+ branches:
11
+ - main
12
+ paths-ignore:
13
+ - "**.md"
14
+
15
+ jobs:
16
+ Test:
17
+ runs-on: ubuntu-24.04
18
+ strategy:
19
+ matrix:
20
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
21
+ fail-fast: false
22
+
23
+ steps:
24
+ - uses: actions/checkout@v6
25
+ - name: Set up Python ${{ matrix.python-version }}
26
+ uses: actions/setup-python@v6
27
+ with:
28
+ python-version: ${{ matrix.python-version }}
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install ruff
33
+ pip install -e ".[dev]"
34
+ - name: Test with pytest
35
+ run: |
36
+ pytest --cov=keepassxc_ssh_agent --cov-report=term-missing
37
+ - name: Lint with ruff
38
+ env:
39
+ PY_VER: ${{ matrix.python-version }}
40
+ run: |
41
+ PY_VER=$(echo py${PY_VER} | tr -d '.')
42
+ ruff check --output-format=github --ignore=E501 --exclude=__init__.py --target-version=${PY_VER} ./keepassxc_ssh_agent
43
+
44
+ Check-Test:
45
+ if: ${{ always() }}
46
+ runs-on: ubuntu-24.04
47
+ needs:
48
+ - Test
49
+ steps:
50
+ - run: |
51
+ result="${{ needs.Test.result }}"
52
+ if [[ $result == "success" || $result == "skipped" ]]; then
53
+ exit 0
54
+ else
55
+ exit 1
56
+ fi
@@ -0,0 +1,76 @@
1
+ name: Build & Upload Python Package
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+
8
+ jobs:
9
+ Setup:
10
+ runs-on: ubuntu-24.04
11
+ outputs:
12
+ version: ${{ steps.set-version.outputs.version }}
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v6
16
+ with:
17
+ fetch-depth: 0
18
+ - name: Get Version
19
+ id: set-version
20
+ env:
21
+ VERSION: ${{ github.ref_name }}
22
+ run: |
23
+ if grep -c -E '^v[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}$' <<< ${VERSION}; then
24
+ VERSION=$(sed 's/^.\{1\}//g' <<< ${VERSION})
25
+ else
26
+ echo "This branch shouldn't be build: ${VERSION}"
27
+ exit 1
28
+ fi
29
+ echo "version=$(echo ${VERSION})" >> $GITHUB_OUTPUT
30
+
31
+ Deploy:
32
+ runs-on: ubuntu-24.04
33
+ needs: Setup
34
+ environment:
35
+ name: pypi
36
+ url: https://pypi.org/p/keepassxc-ssh-agent/
37
+ permissions:
38
+ id-token: write
39
+ contents: read
40
+ steps:
41
+ - uses: actions/checkout@v6
42
+ with:
43
+ fetch-depth: 0
44
+ - name: Set up Python
45
+ uses: actions/setup-python@v6
46
+ with:
47
+ python-version: '3.x'
48
+ - name: Install dependencies
49
+ run: |
50
+ python -m pip install --upgrade pip
51
+ pip install build
52
+ - name: Build package
53
+ env:
54
+ SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.Setup.outputs.version }}
55
+ run: python -m build
56
+ - name: Publish package
57
+ uses: pypa/gh-action-pypi-publish@v1.13.0
58
+
59
+ Notify-Homebrew:
60
+ runs-on: ubuntu-24.04
61
+ needs: [Setup, Deploy]
62
+ steps:
63
+ - uses: actions/create-github-app-token@v2
64
+ id: generate-token
65
+ with:
66
+ app-id: ${{ secrets.APP_ID_MERGE }}
67
+ private-key: ${{ secrets.APP_PRIVATE_KEY_MERGE }}
68
+ owner: ${{ github.repository_owner }}
69
+ repositories: homebrew-tap
70
+ - name: Trigger Homebrew formula update
71
+ env:
72
+ GH_TOKEN: ${{ steps.generate-token.outputs.token }}
73
+ run: |
74
+ gh api repos/${{ github.repository_owner }}/homebrew-tap/dispatches \
75
+ -f event_type=update-formula \
76
+ -f "client_payload[version]=${{ needs.Setup.outputs.version }}"
@@ -0,0 +1,216 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+
204
+ # Ruff stuff:
205
+ .ruff_cache/
206
+
207
+ # PyPI configuration file
208
+ .pypirc
209
+
210
+ # Marimo
211
+ marimo/_static/
212
+ marimo/_lsp/
213
+ __marimo__/
214
+
215
+ # Streamlit
216
+ .streamlit/secrets.toml
@@ -0,0 +1,74 @@
1
+ # KeePassXC SSH Agent - Claude Code Instructions
2
+
3
+ ## Project Overview
4
+
5
+ Standalone Python tool - an SSH IdentityAgent proxy for macOS that triggers KeePassXC database unlock (via TouchID) when SSH keys are needed.
6
+
7
+ ## Architecture
8
+
9
+ - **Proxy pattern**: SSH Client → keepassxc-ssh-agent (Unix socket) → System ssh-agent
10
+ - **Unlock trigger**: Uses KeePassXC's browser extension protocol (NaCl-encrypted JSON over Unix socket)
11
+ - **No signing**: The proxy does NOT implement SSH key signing. KeePassXC pushes keys to the system ssh-agent on unlock, and the proxy forwards requests there.
12
+ - **SSH_AUTH_SOCK interception**: Renames the real ssh-agent socket to `.system` suffix and symlinks the original path to the proxy socket. Restores on shutdown.
13
+
14
+ ### Key Files
15
+
16
+ - `keepassxc_ssh_agent/server.py` - SSH agent proxy server (threading-based, Unix socket)
17
+ - `keepassxc_ssh_agent/browser_client.py` - KeePassXC browser extension protocol client (NaCl crypto)
18
+ - `keepassxc_ssh_agent/ssh_agent_protocol.py` - SSH agent wire format (4-byte length prefix + message)
19
+ - `keepassxc_ssh_agent/config.py` - Config persistence (`~/.keepassxc/ssh-agent.json`)
20
+ - `keepassxc_ssh_agent/__main__.py` - CLI with subcommands: install, run, status, uninstall
21
+
22
+ ### KeePassXC Browser Protocol Details
23
+
24
+ - Socket: `$TMPDIR/org.keepassxc.KeePassXC.BrowserServer` (macOS), `$XDG_RUNTIME_DIR/app/org.keepassxc.KeePassXC/org.keepassxc.KeePassXC.BrowserServer` (Linux)
25
+ - Every JSON message MUST include a `clientID` field (KeePassXC silently drops messages without it)
26
+ - Key exchange via `change-public-keys` (unencrypted), all subsequent messages use NaCl `crypto_box`
27
+ - `openDatabase(triggerUnlock=true)` is NON-BLOCKING - returns immediately, must poll for unlock
28
+ - `test-associate` only works when DB is unlocked
29
+ - Relevant KeePassXC source files (in KeePassXC repo): `src/browser/BrowserAction.cpp`, `src/browser/BrowserService.cpp`
30
+
31
+ ## Commands
32
+
33
+ ```shell
34
+ # Install
35
+ pip install -e ".[dev]"
36
+
37
+ # Run tests
38
+ pytest
39
+
40
+ # Run tests with coverage
41
+ pytest --cov=keepassxc_ssh_agent
42
+
43
+ # Lint
44
+ ruff check --ignore=E501 --exclude=__init__.py ./keepassxc_ssh_agent
45
+ ```
46
+
47
+ ## Conventions
48
+
49
+ - Python >= 3.10, no async (threading-based for simplicity)
50
+ - `from __future__ import annotations` in all source files for modern type syntax (`X | None`)
51
+ - PyNaCl for NaCl crypto (not raw libsodium)
52
+ - Config files use 0600 permissions (owner-only)
53
+ - Tests use `short_tmp` fixture for Unix socket paths (macOS `tmp_path` is too long for AF_UNIX)
54
+ - LaunchAgent label: `org.keepassxc.ssh-agent`
55
+
56
+ ## Known Limitations
57
+
58
+ - macOS only (browser extension socket path is platform-specific)
59
+ - If DB is unlocked but ssh-agent is cleared (`ssh-add -D`), keys won't reload without lock/unlock cycle
60
+ - `triggerUnlock` only works for the active database tab in KeePassXC
61
+
62
+ ## Homebrew
63
+
64
+ - Tap repo: `mietzen/homebrew-tap` (access locally via `cd $(brew --repository mietzen/homebrew-tap)`)
65
+ - Formula: `Formula/keepassxc-ssh-agent.rb` — uses `Language::Python::Virtualenv`, depends on python@3.13, libsodium
66
+ - Service managed via `brew services` (not the tool's own LaunchAgent when installed via Homebrew)
67
+ - Formula auto-updated on new PyPI releases via `repository_dispatch` from `pypi.yml`
68
+
69
+ ## CI
70
+
71
+ - `lint_and_test.yml` - Unit tests + ruff lint across Python 3.10-3.14
72
+ - `pypi.yml` - Build & publish on release, then dispatch to homebrew-tap to update the formula
73
+ - `auto-release.yml` - Auto-create patch release on dependabot merge
74
+ - `auto-merge-dependabot.yml` - Auto-merge dependabot PRs
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nils Stein
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.