Skip to content

支持 SSH 密钥密码短语验证,添加 cryptography 依赖#2

Merged
codeskyblue merged 2 commits into
masterfrom
feat/20260616-ssh-key-passphrase
Jun 16, 2026
Merged

支持 SSH 密钥密码短语验证,添加 cryptography 依赖#2
codeskyblue merged 2 commits into
masterfrom
feat/20260616-ssh-key-passphrase

Conversation

@codeskyblue

Copy link
Copy Markdown
Owner

No description provided.

- 新增 _resolve_key_passphrase() 函数,通过 cryptography 库解析密钥并提示输入密码短语
- HostConfig 添加 get_password() 方法处理整数类型密码
- 添加 poetry.toml 配置 in-project 虚拟环境
- 更新 dev-dependencies 为新的 poetry group 格式
Copilot AI review requested due to automatic review settings June 16, 2026 03:43

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

该 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_passphraseHostConfig.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 thread sshg.py Outdated
Comment thread sshg.py
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>
@codeskyblue codeskyblue merged commit 70a80ec into master Jun 16, 2026
2 checks passed
@codeskyblue codeskyblue deleted the feat/20260616-ssh-key-passphrase branch June 16, 2026 05:09
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.

2 participants