支持 SSH 密钥密码短语验证,添加 cryptography 依赖#2
Merged
Conversation
- 新增 _resolve_key_passphrase() 函数,通过 cryptography 库解析密钥并提示输入密码短语 - HostConfig 添加 get_password() 方法处理整数类型密码 - 添加 poetry.toml 配置 in-project 虚拟环境 - 更新 dev-dependencies 为新的 poetry group 格式
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 旨在为 sshg 增加对 SSH 私钥口令(passphrase) 的处理能力:当配置未提供密码但使用了带口令的私钥时,程序会提示输入口令并用于登录。同时引入 cryptography 依赖,并调整 Poetry 配置以支持新的依赖/开发依赖分组。
Changes:
- 在
sshg.py中新增私钥口令解析逻辑,并在pxssh.login()时统一使用字符串形式的 password。 - 在
pyproject.toml中添加cryptography运行时依赖,并将 dev 依赖迁移到 Poetry group 配置。 - 新增
poetry.toml以启用 in-project virtualenv。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| sshg.py | 增加私钥口令解析 _resolve_key_passphrase 与 HostConfig.get_password(),并将 login 传参改为字符串口令 |
| pyproject.toml | 添加 cryptography 依赖并迁移 dev 依赖到 [tool.poetry.group.dev.dependencies] |
| poetry.toml | 配置 Poetry 在项目内创建虚拟环境 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+159
to
+163
| def _resolve_key_passphrase(keypath: pathlib.Path) -> str: | ||
| """Try loading key without passphrase, prompt until correct if needed.""" | ||
| from cryptography.hazmat.primitives.serialization import load_pem_private_key, load_ssh_private_key | ||
|
|
||
| key_data = keypath.read_bytes() |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.